firmware: arm_scmi: quirk: Fix CLOCK_DESCRIBE_RATES triplet

Convert an existing quirk in CLOCK_DESCRIBE_RATES parsing to the new quirk
framework. This is a sort of a peculiar quirk since it matches any platform
and any firmware.

Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Message-Id: <20250429141108.406045-4-cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
This commit is contained in:
Cristian Marussi 2025-04-29 15:11:08 +01:00 committed by Sudeep Holla
parent 487c407d57
commit 7b487beab7
3 changed files with 25 additions and 13 deletions

View File

@ -11,6 +11,7 @@
#include "protocols.h"
#include "notify.h"
#include "quirks.h"
/* Updated only after ALL the mandatory features for that version are merged */
#define SCMI_PROTOCOL_SUPPORTED_VERSION 0x30000
@ -429,6 +430,23 @@ static void iter_clk_describe_prepare_message(void *message,
msg->rate_index = cpu_to_le32(desc_index);
}
#define QUIRK_OUT_OF_SPEC_TRIPLET \
({ \
/* \
* A known quirk: a triplet is returned but num_returned != 3 \
* Check for a safe payload size and fix. \
*/ \
if (st->num_returned != 3 && st->num_remaining == 0 && \
st->rx_len == sizeof(*r) + sizeof(__le32) * 2 * 3) { \
st->num_returned = 3; \
st->num_remaining = 0; \
} else { \
dev_err(p->dev, \
"Cannot fix out-of-spec reply !\n"); \
return -EPROTO; \
} \
})
static int
iter_clk_describe_update_state(struct scmi_iterator_state *st,
const void *response, void *priv)
@ -450,19 +468,8 @@ iter_clk_describe_update_state(struct scmi_iterator_state *st,
p->clk->name, st->num_returned, st->num_remaining,
st->rx_len);
/*
* A known quirk: a triplet is returned but num_returned != 3
* Check for a safe payload size and fix.
*/
if (st->num_returned != 3 && st->num_remaining == 0 &&
st->rx_len == sizeof(*r) + sizeof(__le32) * 2 * 3) {
st->num_returned = 3;
st->num_remaining = 0;
} else {
dev_err(p->dev,
"Cannot fix out-of-spec reply !\n");
return -EPROTO;
}
SCMI_QUIRK(clock_rates_triplet_out_of_spec,
QUIRK_OUT_OF_SPEC_TRIPLET);
}
return 0;

View File

@ -169,6 +169,7 @@ struct scmi_quirk {
__DEFINE_SCMI_QUIRK_ENTRY(_qn, _ven, _sub, _impl, ##__VA_ARGS__)
/* Global Quirks Definitions */
DEFINE_SCMI_QUIRK(clock_rates_triplet_out_of_spec, NULL, NULL, NULL);
/*
* Quirks Pointers Array
@ -177,6 +178,7 @@ struct scmi_quirk {
* defined quirks descriptors.
*/
static struct scmi_quirk *scmi_quirks_table[] = {
__DECLARE_SCMI_QUIRK_ENTRY(clock_rates_triplet_out_of_spec),
NULL
};

View File

@ -45,4 +45,7 @@ static inline void scmi_quirks_enable(struct device *dev, const char *vend,
#endif /* CONFIG_ARM_SCMI_QUIRKS */
/* Quirk delarations */
DECLARE_SCMI_QUIRK(clock_rates_triplet_out_of_spec);
#endif /* _SCMI_QUIRKS_H */