The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [RFC PATCH v2] firmware: arm_scmi: quirk: Allow CLOCK_ATTRIBUTES with missing latency
@ 2026-11-29 19:37 Cristian Marussi
  2026-12-01  9:08 ` Lucas Tanure
  0 siblings, 1 reply; 2+ messages in thread
From: Cristian Marussi @ 2026-11-29 19:37 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, arm-scmi
  Cc: sudeep.holla, philip.radford, tanure, Cristian Marussi

Allow for out-of-spec CLOCK_ATTRIBUTES replies with missing latency field.

Reported-by: Lucas Tanure <tanure@linux.com>
Closes: https://lore.kernel.org/arm-scmi/CAJX_Q+21a1UVE1CCXEGQc4-pdgu_fu32ohxspg5h=Sw7zPdKdQ@mail.gmail.com/
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
RFC since it ahas to be tested on AMLOGC affected devices and maybe the quirk
matching rules updated.

v1 --> v2
 - also access to the field MUST not be attempted, as reported by Sashiko
---
 drivers/firmware/arm/scmi/clock.c  | 20 ++++++++++++++++++++
 drivers/firmware/arm/scmi/quirks.c |  2 ++
 drivers/firmware/arm/scmi/quirks.h |  1 +
 3 files changed, 23 insertions(+)

diff --git a/drivers/firmware/arm/scmi/clock.c b/drivers/firmware/arm/scmi/clock.c
index ed93970c3b87..08f0db58661a 100644
--- a/drivers/firmware/arm/scmi/clock.c
+++ b/drivers/firmware/arm/scmi/clock.c
@@ -355,6 +355,19 @@ scmi_clock_get_permissions(const struct scmi_protocol_handle *ph, u32 clk_id,
 	return ret;
 }
 
+#define QUIRK_CLK_ATTRIBUTES_LATENCY_MISSING				 \
+({									 \
+	/* Ignore clock_enable_latency, always missing in the reply */	 \
+	if (PROTOCOL_REV_MAJOR(ph->version) >= 0x2)			 \
+		rx_size = offsetof(struct scmi_msg_resp_clock_attributes,\
+				   clock_enable_latency);		 \
+})
+
+#define QUIRK_CLK_ATTRIBUTES_LATENCY_IGNORED	\
+({						\
+	clk->enable_latency = U32_MAX;		\
+})
+
 static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph,
 				     u32 clk_id, struct clock_info *cinfo)
 {
@@ -368,6 +381,8 @@ static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph,
 	if (PROTOCOL_REV_MAJOR(ph->version) < 0x2)
 		rx_size -= sizeof(attr->clock_enable_latency);
 
+	SCMI_QUIRK(clock_attributes_latency_missing,
+		   QUIRK_CLK_ATTRIBUTES_LATENCY_MISSING);
 	ret = ph->xops->xfer_get_init(ph, CLOCK_ATTRIBUTES,
 				      sizeof(clk_id), rx_size, &t);
 	if (ret)
@@ -386,6 +401,9 @@ static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph,
 		if (PROTOCOL_REV_MAJOR(ph->version) >= 0x2)
 			latency = le32_to_cpu(attr->clock_enable_latency);
 		clk->enable_latency = latency ? : U32_MAX;
+
+		SCMI_QUIRK(clock_attributes_latency_missing,
+			   QUIRK_CLK_ATTRIBUTES_LATENCY_IGNORED);
 	}
 
 	ph->xops->xfer_put(ph, t);
@@ -1014,6 +1032,8 @@ scmi_clock_config_get(const struct scmi_protocol_handle *ph, u32 clk_id,
 	if (PROTOCOL_REV_MAJOR(ph->version) < 0x2)
 		rx_size -= sizeof(resp->clock_enable_latency);
 
+	SCMI_QUIRK(clock_attributes_latency_missing,
+		   QUIRK_CLK_ATTRIBUTES_LATENCY_MISSING);
 	ret = ph->xops->xfer_get_init(ph, CLOCK_ATTRIBUTES,
 				      sizeof(clk_id), rx_size, &t);
 	if (ret)
diff --git a/drivers/firmware/arm/scmi/quirks.c b/drivers/firmware/arm/scmi/quirks.c
index 9ed5ce4feded..f07de6b9b7f4 100644
--- a/drivers/firmware/arm/scmi/quirks.c
+++ b/drivers/firmware/arm/scmi/quirks.c
@@ -172,6 +172,7 @@ struct scmi_quirk {
 /* Global Quirks Definitions */
 DEFINE_SCMI_QUIRK(clock_rates_triplet_out_of_spec, NULL, NULL, NULL);
 DEFINE_SCMI_QUIRK(perf_level_get_fc_force, "Qualcomm", NULL, "0x20000-");
+DEFINE_SCMI_QUIRK(clock_attributes_latency_missing, "AMLOGIC", NULL, "0x0");
 
 /*
  * Quirks Pointers Array
@@ -182,6 +183,7 @@ DEFINE_SCMI_QUIRK(perf_level_get_fc_force, "Qualcomm", NULL, "0x20000-");
 static struct scmi_quirk *scmi_quirks_table[] = {
 	__DECLARE_SCMI_QUIRK_ENTRY(clock_rates_triplet_out_of_spec),
 	__DECLARE_SCMI_QUIRK_ENTRY(perf_level_get_fc_force),
+	__DECLARE_SCMI_QUIRK_ENTRY(clock_attributes_latency_missing),
 	NULL
 };
 
diff --git a/drivers/firmware/arm/scmi/quirks.h b/drivers/firmware/arm/scmi/quirks.h
index d8ba60b95652..11b57ffb2d4d 100644
--- a/drivers/firmware/arm/scmi/quirks.h
+++ b/drivers/firmware/arm/scmi/quirks.h
@@ -48,5 +48,6 @@ static inline void scmi_quirks_enable(struct device *dev, const char *vend,
 /* Quirk delarations */
 DECLARE_SCMI_QUIRK(clock_rates_triplet_out_of_spec);
 DECLARE_SCMI_QUIRK(perf_level_get_fc_force);
+DECLARE_SCMI_QUIRK(clock_attributes_latency_missing);
 
 #endif /* _SCMI_QUIRKS_H */
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-01  9:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 19:37 [RFC PATCH v2] firmware: arm_scmi: quirk: Allow CLOCK_ATTRIBUTES with missing latency Cristian Marussi
2026-12-01  9:08 ` Lucas Tanure

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox