Skip to contentSkip to conversation

clk: scmi: various fixes

PATCH Applied Patrice Chotard 2 participants 5 messages Dec 18, 2025 – Jan 5 Common clk

lore
Share & tools
lore
#0 lore raw

v5 cover clk: scmi: various fixes

- Fix typo scmi_clk_get_attibute.
- Fix priv initialization in scmi_clk_gate() which leads to clock_enable() error when CONFIG_CLK_CCF is not set.
- Remove duplicated scmi_generic_protocol_version() call in scmi_clk_probe().

---
Changes in v5:
- Remove blank line in patch 2 commit message.
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- Update commit message of patch 1.
- Expand comment of patch 2.
- Fix CC, AB/RB/TB tags.
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- invert CLK_CCF conditional in scmi_clk_gate().
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Add Peng Fan's Reviewed-by.
- Add comment in scmi_clk_gate()
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Patrice Chotard (3):
clk: scmi: Fix typo scmi_clk_get_attibute
clk: scmi: Fix priv initialization in scmi_clk_gate()
clk: scmi: Remove duplicated scmi_generic_protocol_version() request

 drivers/clk/clk_scmi.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

---
base-commit: c5e6d2ab7eba68cbfb600cdc131c0c375ced2ec9
change-id: 20251208-sqqs-7884dbfd4fa7

Best regards,

Signature · 1 line
Patrice Chotard <[email protected]>
#1 lore raw

PATCH v5 1/3 clk: scmi: Fix typo scmi_clk_get_attibute

Fix typo attibute, rename scmi_clk_get_attibute() to scmi_clk_get_attribute().

---
Cc: Alice Guo <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Patrick Delaunay <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Sean Anderson <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Valentin Caron <[email protected]>
Cc: Vinh Nguyen <[email protected]>
Cc: [email protected]

---
 drivers/clk/clk_scmi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/clk/clk_scmi.c +4 -4
index 683ac822a01..f6132178205 100644
@@ -87,8 +87,8 @@ static int scmi_clk_get_num_clock(struct udevice *dev, size_t *num_clocks)
 	return 0;
 }
 
-static int scmi_clk_get_attibute(struct udevice *dev, int clkid, char *name,
-				 u32 *attr)
+static int scmi_clk_get_attribute(struct udevice *dev, int clkid, char *name,
+				  u32 *attr)
 {
 	struct scmi_clock_priv *priv = dev_get_priv(dev);
 	struct scmi_clk_attribute_in in = {
@@ -183,8 +183,8 @@ static int scmi_clk_get_ctrl_flags(struct clk *clk, u32 *ctrl_flags)
 
 	if (!clkscmi->attrs_resolved) {
 		char name[SCMI_CLOCK_NAME_LENGTH_MAX];
-		ret = scmi_clk_get_attibute(dev, clk->id & CLK_ID_MSK,
-					    name, &attributes);
+		ret = scmi_clk_get_attribute(dev, clk->id & CLK_ID_MSK,
+					     name, &attributes);
 		if (ret)
 			return ret;
 
Signature · 1 line
2.43.0
#2 lore raw

PATCH v5 2/3 clk: scmi: Fix priv initialization in scmi_clk_gate()

In reply to Patrice Chotard

In scmi_clk_probe(), in case of CLK_CCF is not enabled, parent private data is not set, so in scmi_clk_gate(), an uninitialized priv struct is retrieved.

SCMI request is performed either using scmi_clk_state_in_v1 or scmi_clk_state_in_v2 struct depending of the unpredictable value of priv->version which leads to error during SCMI clock enable.

Issue detected on STM32MP157C-DK2 board using the SCMI device tree stm32mp157c-dk2-scmi.dts.

Fixes 0619cb32030b ("firmware: scmi: Add clock v3.2 CONFIG_SET support")

---
Cc: Alice Guo <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Patrick Delaunay <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Sean Anderson <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Valentin Caron <[email protected]>
Cc: Vinh Nguyen <[email protected]>
Cc: [email protected]

---
 drivers/clk/clk_scmi.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/clk/clk_scmi.c +11 -1
index f6132178205..a4fc4f8da89 100644
@@ -137,7 +137,7 @@ static int scmi_clk_get_attribute(struct udevice *dev, int clkid, char *name,
 
 static int scmi_clk_gate(struct clk *clk, int enable)
 {
-	struct scmi_clock_priv *priv = dev_get_parent_priv(clk->dev);
+	struct scmi_clock_priv *priv;
 	struct scmi_clk_state_in_v1 in_v1 = {
 		.clock_id = clk_get_id(clk),
 		.attributes = enable,
@@ -156,6 +156,16 @@ static int scmi_clk_gate(struct clk *clk, int enable)
 					     in_v2, out);
 	int ret;
 
+	/*
+	 * In scmi_clk_probe(), in case of CLK_CCF is set, SCMI clock
+	 * version is set in dev's parent priv struct. Otherwise
+	 * SCMI clock version is set in dev priv struct.
+	 */
+	if (CONFIG_IS_ENABLED(CLK_CCF))
+		priv = dev_get_parent_priv(clk->dev);
+	else
+		priv = dev_get_priv(clk->dev);
+
 	ret = devm_scmi_process_msg(clk->dev,
 				    (priv->version < CLOCK_PROTOCOL_VERSION_2_1) ?
 				    &msg_v1 : &msg_v2);
Signature · 1 line
2.43.0
#3 lore raw

PATCH v5 3/3 clk: scmi: Remove duplicated scmi_generic_protocol_version() request

In reply to Patrice Chotard

scmi_generic_protocol_version() request is done twice in scmi_clk_probe(). Remove first call which is useless.

Fixes ae7e0330ce22 ("clk: scmi: add compatibility with clock protocol 2.0")

---
Cc: Alice Guo <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Patrick Delaunay <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Sean Anderson <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Valentin Caron <[email protected]>
Cc: Vinh Nguyen <[email protected]>
Cc: [email protected]

---
 drivers/clk/clk_scmi.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/clk/clk_scmi.c +0 -3
index a4fc4f8da89..ee237ed6337 100644
@@ -344,9 +344,6 @@ static int scmi_clk_probe(struct udevice *dev)
 	if (!CONFIG_IS_ENABLED(CLK_CCF))
 		return 0;
 
-	ret = scmi_generic_protocol_version(dev, SCMI_PROTOCOL_ID_CLOCK,
-					    &priv->version);
-
 	/* register CCF children: CLK UCLASS, no probed again */
 	if (device_get_uclass_id(dev->parent) == UCLASS_CLK)
 		return 0;
Signature · 1 line
2.43.0
Applied
#4 lore raw
In reply to Patrice Chotard
Quoted 8 lines · Patrice Chotard

- Fix typo scmi_clk_get_attibute.
- Fix priv initialization in scmi_clk_gate() which leads to clock_enable() error when CONFIG_CLK_CCF is not set.
- Remove duplicated scmi_generic_protocol_version() call in scmi_clk_probe().

Applied!

Thanks,
Peng