clk: scmi: various fixes
v4 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 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]>
PATCH v4 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
@@ -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
Re: [PATCH v4 1/3] clk: scmi: Fix typo scmi_clk_get_attibute
Quoted 2 lines · Patrice Chotard
Fix typo attibute, rename
scmi_clk_get_attibute()toscmi_clk_get_attribute().
PATCH v4 2/3 clk: scmi: Fix priv initialization in scmi_clk_gate()
In reply to Patrice ChotardIn 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.
---
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
@@ -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
Re: [PATCH v4 2/3] clk: scmi: Fix priv initialization in scmi_clk_gate()
Quoted 45 lines · Patrice Chotard
In
scmi_clk_probe(), in case ofCLK_CCFis not enabled, parent private data is not set, so inscmi_clk_gate(), an uninitialized priv struct is retrieved.SCMI request is performed either using
scmi_clk_state_in_v1orscmi_clk_state_in_v2struct depending of the unpredictable value ofpriv->versionwhich 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")Reviewed-by Peng Fan <[email protected]>Signed-off-by Patrice Chotard <[email protected]>---
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 +1
-1@@ -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;
drivers/clk/clk_scmi.c static int scmi_clk_gate(struct clk *clk, int enable) · line 167
Quoted 10 lines
drivers/clk/clk_scmi.c +9
-0+/* +* 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);
On your hardware, do you have CCF enabled or not ?
What does this print output if added here ?
printf("clk->dev->name=%s clk->dev->parent->name=%s\n", clk->dev->name, clk->dev->parent->name);
I think it should be something like this:
clk->dev->name=scmi-325 clk->dev->parent->name=protocol@14
Re: [PATCH v4 2/3] clk: scmi: Fix priv initialization in scmi_clk_gate()
Quoted 47 lines · Marek Vasut
Quoted 46 lines · Patrice Chotard
In
scmi_clk_probe(), in case ofCLK_CCFis not enabled, parent private data is not set, so inscmi_clk_gate(), an uninitialized priv struct is retrieved.SCMI request is performed either using
scmi_clk_state_in_v1orscmi_clk_state_in_v2struct depending of the unpredictable value ofpriv->versionwhich 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")Reviewed-by Peng Fan <[email protected]>Signed-off-by Patrice Chotard <[email protected]>---
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 +1
-1@@ -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;+ /*
+ * Inscmi_clk_probe(), in case ofCLK_CCFis set, SCMI clock
Quoted 8 lines
Quoted 7 lines
+ * 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);On your hardware, do you have CCF enabled or not ?
On stm32mp15, CCF is not set.
Quoted 8 lines
What does this print output if added here ?
printf("clk->dev->name=%s clk->dev->parent->name=%s\n", clk->dev->name, clk->dev->parent->name);I think it should be something like this:
clk->dev->name=scmi-325 clk->dev->parent->name=protocol@14
I got
clk->dev->name=protocol@14 clk->dev->parent->name=scmi
Marek Vasut
Reviewed-byRe: [PATCH v4 2/3] clk: scmi: Fix priv initialization in scmi_clk_gate()
On 12/18/25 10:58 AM, Patrice CHOTARD wrote:
Hello Patrice,
Quoted 21 lines
Quoted 5 lines
Quoted 5 lines
drivers/clk/clk_scmi.c +1
-0@@ -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 Quoted 8 lines
drivers/clk/clk_scmi.c static int scmi_clk_gate(struct clk *clk, int enable) · line 167
Quoted 7 lines
drivers/clk/clk_scmi.c +7
-0+* 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);On your hardware, do you have CCF enabled or not ?
On stm32mp15, CCF is not set.
Quoted 5 lines
What does this print output if added here ?
printf("clk->dev->name=%s clk->dev->parent->name=%s\n", clk->dev->name, clk->dev->parent->name);
Quoted 7 lines
Quoted 3 lines
I think it should be something like this:
clk->dev->name=scmi-325 clk->dev->parent->name=protocol@14
I got
clk->dev->name=protocol@14 clk->dev->parent->name=scmi
I see.
PATCH v4 3/3 clk: scmi: Remove duplicated scmi_generic_protocol_version() request
In reply to Patrice Chotardscmi_generic_protocol_version() request is done twice in scmi_clk_probe(). Remove first call which is useless.
---
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
@@ -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
Re: [PATCH v4 3/3] clk: scmi: Remove duplicated scmi_generic_protocol_version() request
Quoted 5 lines · Patrice Chotard
scmi_generic_protocol_version()request is done twice inscmi_clk_probe(). Remove first call which is useless.Fixes ae7e0330ce22 ("clk: scmi: add compatibility with clock protocol 2.0")
The newline ^ should not be here.
Quoted 3 lines
Reviewed-by Peng Fan <[email protected]>Reviewed-by Marek Vasut <[email protected]>Signed-off-by Patrice Chotard <[email protected]>
[...]