Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Cristian Marussi and committed by
Sudeep Holla
7b487bea 487c407d

+25 -13
+20 -13
drivers/firmware/arm_scmi/clock.c
··· 11 11 12 12 #include "protocols.h" 13 13 #include "notify.h" 14 + #include "quirks.h" 14 15 15 16 /* Updated only after ALL the mandatory features for that version are merged */ 16 17 #define SCMI_PROTOCOL_SUPPORTED_VERSION 0x30000 ··· 430 429 msg->rate_index = cpu_to_le32(desc_index); 431 430 } 432 431 432 + #define QUIRK_OUT_OF_SPEC_TRIPLET \ 433 + ({ \ 434 + /* \ 435 + * A known quirk: a triplet is returned but num_returned != 3 \ 436 + * Check for a safe payload size and fix. \ 437 + */ \ 438 + if (st->num_returned != 3 && st->num_remaining == 0 && \ 439 + st->rx_len == sizeof(*r) + sizeof(__le32) * 2 * 3) { \ 440 + st->num_returned = 3; \ 441 + st->num_remaining = 0; \ 442 + } else { \ 443 + dev_err(p->dev, \ 444 + "Cannot fix out-of-spec reply !\n"); \ 445 + return -EPROTO; \ 446 + } \ 447 + }) 448 + 433 449 static int 434 450 iter_clk_describe_update_state(struct scmi_iterator_state *st, 435 451 const void *response, void *priv) ··· 468 450 p->clk->name, st->num_returned, st->num_remaining, 469 451 st->rx_len); 470 452 471 - /* 472 - * A known quirk: a triplet is returned but num_returned != 3 473 - * Check for a safe payload size and fix. 474 - */ 475 - if (st->num_returned != 3 && st->num_remaining == 0 && 476 - st->rx_len == sizeof(*r) + sizeof(__le32) * 2 * 3) { 477 - st->num_returned = 3; 478 - st->num_remaining = 0; 479 - } else { 480 - dev_err(p->dev, 481 - "Cannot fix out-of-spec reply !\n"); 482 - return -EPROTO; 483 - } 453 + SCMI_QUIRK(clock_rates_triplet_out_of_spec, 454 + QUIRK_OUT_OF_SPEC_TRIPLET); 484 455 } 485 456 486 457 return 0;
+2
drivers/firmware/arm_scmi/quirks.c
··· 169 169 __DEFINE_SCMI_QUIRK_ENTRY(_qn, _ven, _sub, _impl, ##__VA_ARGS__) 170 170 171 171 /* Global Quirks Definitions */ 172 + DEFINE_SCMI_QUIRK(clock_rates_triplet_out_of_spec, NULL, NULL, NULL); 172 173 173 174 /* 174 175 * Quirks Pointers Array ··· 178 177 * defined quirks descriptors. 179 178 */ 180 179 static struct scmi_quirk *scmi_quirks_table[] = { 180 + __DECLARE_SCMI_QUIRK_ENTRY(clock_rates_triplet_out_of_spec), 181 181 NULL 182 182 }; 183 183
+3
drivers/firmware/arm_scmi/quirks.h
··· 45 45 46 46 #endif /* CONFIG_ARM_SCMI_QUIRKS */ 47 47 48 + /* Quirk delarations */ 49 + DECLARE_SCMI_QUIRK(clock_rates_triplet_out_of_spec); 50 + 48 51 #endif /* _SCMI_QUIRKS_H */