[PATCH 3/4] clk: scmi: Postpone clock name resolution
    Peng Fan 
    peng.fan at oss.nxp.com
       
    Tue Oct 28 12:56:45 CET 2025
    
    
  
Hi Marek,
On Tue, Oct 28, 2025 at 04:41:05AM +0100, Marek Vasut wrote:
>The clock names are retrived via SCMI_CLOCK_ATTRIBUTES, called for each
>clock ID. This may take a lot of time to complete and is not strictly
>necessary. Register each clock as "scmi-%zu" instead, and let the first
>call of SCMI_CLOCK_ATTRIBUTES fill in the actual clock name.
>
>This has a side effect, which can be considered both an upside and also
>a downside. Unused clock are never renamed and retain their placeholder
>"scmi-%zu" name, which avoids empty clock names for nameless SCMI clock,
>and avoids the name resolution and improves boot time. But for those
>SCMI clock which do have name, that name is not listed until the clock
>are used.
>
>This is a preparatory patch for deferred issue of SCMI_CLOCK_ATTRIBUTES.
>
>Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
>---
>Cc: Alice Guo <alice.guo at nxp.com>
>Cc: Patrice Chotard <patrice.chotard at foss.st.com>
>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 | 25 +++++++++++--------------
> 1 file changed, 11 insertions(+), 14 deletions(-)
>
>diff --git a/drivers/clk/clk_scmi.c b/drivers/clk/clk_scmi.c
>index 3ee2df0ca9b..afaeb84e65d 100644
>--- a/drivers/clk/clk_scmi.c
>+++ b/drivers/clk/clk_scmi.c
>@@ -16,6 +16,7 @@
> 
> struct clk_scmi {
> 	struct clk clk;
>+	char name[SCMI_CLOCK_NAME_LENGTH_MAX];
> 	u32 ctrl_flags;
> };
> 
>@@ -325,24 +326,20 @@ static int scmi_clk_probe(struct udevice *dev)
> 		return -ENOMEM;
> 
> 	for (i = 0; i < num_clocks; i++) {
>-		char *clock_name;
>+		clk_scmi = clk_scmi_bulk + i;
>+		char *clock_name = clk_scmi->name;
> 		u32 attributes;
> 
>-		if (!scmi_clk_get_attibute(dev, i, &clock_name, &attributes)) {
>-			clk_scmi = clk_scmi_bulk + i;
>-			if (!clock_name)
>-				ret = -ENOMEM;
>-			else
>-				ret = clk_register(&clk_scmi->clk, dev->driver->name,
>-						   clock_name, dev->name);
>-
>-			if (ret) {
>-				free(clock_name);
>-				return ret;
>-			}
>+		snprintf(clock_name, SCMI_CLOCK_NAME_LENGTH_MAX, "scmi-%zu", i);
>+
>+		ret = clk_register(&clk_scmi->clk, dev->driver->name,
>+				   clock_name, dev->name);
>+		if (ret)
>+			return ret;
> 
>-			dev_clk_dm(dev, i, &clk_scmi->clk);
>+		dev_clk_dm(dev, i, &clk_scmi->clk);
> 
>+		if (!scmi_clk_get_attibute(dev, i, &clock_name, &attributes)) {
There is still scmi_clk_get_attibute for each clock. In commit log, 
you mentioned this takes lot time to complete. I may miss something,
what is improved in this change?
Thanks,
Peng
> 			if (CLK_HAS_RESTRICTIONS(attributes)) {
> 				u32 perm;
> 
>-- 
>2.51.0
>
    
    
More information about the U-Boot
mailing list