Re: [PATCH] pmdomain: arm: scmi: Check pm_genpd_init() in probe

From: Guangshuo Li

Date: Mon Jul 13 2026 - 08:17:05 EST


Hi Sudeep,

Thanks for the explanation.

On Mon, 6 Jul 2026 at 17:34, Sudeep Holla <sudeep.holla@xxxxxxxxxx> wrote:
>
> On Sun, Jul 05, 2026 at 06:32:56PM +0800, Guangshuo Li wrote:
> > scmi_pm_domain_probe() stores each domain in the onecell domains array
> > after calling pm_genpd_init(), but it ignores the return value from
> > pm_genpd_init().
> >
> > If pm_genpd_init() fails, the genpd has not been added to the global
> > genpd list. The probe code nevertheless stores the genpd pointer in the
> > domains array. A later provider registration failure then unwinds the
> > array with pm_genpd_remove(), which can try to remove a genpd that was
> > never registered.
> >
> > Check the return value from pm_genpd_init() and only store successfully
> > initialized domains in the onecell array. On failure, unwind the domains
> > that were already initialized.
> >
>
> It was done that way intentionally IIRC. We don't want to remove all the
> power domains if some not so important power domains fail to initialise.
> You can log the error if that helps but removing all the domains that
> have initialised seems bit of extreme.
>
> Are you facing any issues on a real platform or is this just by code
> inspection.
>
> --
> Regards,
> Sudeep

This was found through manual code inspection and has not been reproduced
on real hardware. My concern is that a domain for which pm_genpd_init()
fails is still stored in the domains array and may later be passed to
pm_genpd_remove().

I agree that unwinding all initialized domains may be too aggressive.

Thanks,
Guangshuo