[PATCH v4 2/3] clk: scmi: Fix priv initialization in scmi_clk_gate()
Patrice CHOTARD
patrice.chotard at foss.st.com
Thu Dec 18 10:58:44 CET 2025
On 12/18/25 10:13, Marek Vasut wrote:
> On 12/18/25 9:26 AM, Patrice Chotard wrote:
>> 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")
>>
>> Reviewed-by: Peng Fan <peng.fan at nxp.com>
>> Signed-off-by: Patrice Chotard <patrice.chotard at foss.st.com>
>> ---
>> Cc: Alice Guo <alice.guo at nxp.com>
>> Cc: Marek Vasut <marek.vasut+renesas at mailbox.org>
>> Cc: Patrick Delaunay <patrick.delaunay at foss.st.com>
>> Cc: Peng Fan <peng.fan at nxp.com>
>> Cc: Sean Anderson <seanga2 at gmail.com>
>> Cc: Tom Rini <trini at konsulko.com>
>> Cc: Valentin Caron <valentin.caron at foss.st.com>
>> Cc: Vinh Nguyen <vinh.nguyen.xz at renesas.com>
>> Cc: u-boot at lists.denx.de
>> ---
>> drivers/clk/clk_scmi.c | 12 +++++++++++-
>> 1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/clk/clk_scmi.c b/drivers/clk/clk_scmi.c
>> index f6132178205..a4fc4f8da89 100644
>> --- a/drivers/clk/clk_scmi.c
>> +++ b/drivers/clk/clk_scmi.c
>> @@ -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);
> On your hardware, do you have CCF enabled or not ?
On stm32mp15, CCF is not set.
>
> 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 at 14
I got
clk->dev->name=protocol at 14 clk->dev->parent->name=scmi
More information about the U-Boot
mailing list