Re: [PATCH v2] clk: scmi: Fix children encountered before parents case

From: Sascha Hauer
Date: Thu Jun 12 2025 - 04:43:53 EST


On Thu, Jun 12, 2025 at 09:29:16AM +0100, Sudeep Holla wrote:
> On Thu, Jun 12, 2025 at 09:36:58AM +0200, Sascha Hauer wrote:
> > When it comes to clocks with parents the SCMI clk driver assumes that
> > parents are always initialized before their children which might not
> > always be the case.
> >
> > During initialization of the parent_data array we have:
> >
> > sclk->parent_data[i].hw = hws[sclk->info->parents[i]];
> >
> > hws[sclk->info->parents[i]] will not yet be initialized when children
> > are encountered before their possible parents. Solve this by allocating
> > all struct scmi_clk as an array first and populating all hws[] upfront.
> >
>
> LGTM. I would like to add a note that we don't free individual scmi_clk
> if for some reason it fails to setup. I can do that when I apply, just
> checking if anyone has any objections. Please shout out if you have.

Feel free to add that note. I should have added this myself since it's
not entirely obvious that the devm_kfree() has to be removed with this
patch.

Sascha

--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |