Re: [PATCH] PM: domains: Don't attach a device to genpd that corresponds to a provider

From: Ulf Hansson
Date: Fri Jul 09 2021 - 10:03:35 EST


On Fri, 9 Jul 2021 at 15:58, Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote:
>
> Hi Ulf,
>
> On Fri, Jul 9, 2021 at 3:48 PM Ulf Hansson <ulf.hansson@xxxxxxxxxx> wrote:
> > On Fri, 9 Jul 2021 at 15:35, Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote:
> > > On Fri, Jul 9, 2021 at 3:23 PM Ulf Hansson <ulf.hansson@xxxxxxxxxx> wrote:
> > > > On Fri, 9 Jul 2021 at 15:07, Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote:
> > > > > On Fri, Jul 9, 2021 at 2:56 PM Ulf Hansson <ulf.hansson@xxxxxxxxxx> wrote:
> > > > > > According to the common power domain DT bindings, a power domain provider
> > > > > > must have a "#power-domain-cells" property in its OF node. Additionally, if
> > > > > > a provider has a "power-domains" property, it means that it has a parent
> > > > > > domain.
> > > > >
> > > > > OK.
> > > > >
> > > > > > It has turned out that some OF nodes that represents a genpd provider may
> > > > > > also be compatible with a regular platform device. This leads to, during
> > > > > > probe, genpd_dev_pm_attach(), genpd_dev_pm_attach_by_name() and
> > > > > > genpd_dev_pm_attach_by_id() tries to attach the corresponding struct device
> > > > > > to the genpd provider's parent domain, which is wrong. Instead the genpd
> > > > >
> > > > > Why is that wrong?
> > > >
> > > > It may lead to that the struct device that corresponds to a genpd
> > > > provider may be attached to the parent domain. In other words, the
> > > > parent domain will not only be controlled by a child domain
> > > > (corresponding to the provider), but also through the provider's
> > > > struct device. As far as I can tell, this has never been the intent
> > > > for how things should work in genpd.
> > >
> > > Ah, you're worried about the case where the subdomain is a child of
> > > the parent domain, but the actual subdomain controller (represented
> > > by the platform device) isn't?
> >
> > Well, even if the platform device represents a subdomain controller,
> > should it really be attached to the parent domain?
>
> That's what the presence of the "power-domains" property means,
> isn't it?
> If the subdomain controller itself is not part of the parent power
> domain, there should not be a "power-domains" property. So perhaps
> we need a new property ("power-domain-parent"?) to indicate what is
> the parent domain for the subdomains in this case?

Hmm, but perhaps it's just a matter of expectations of what will
happen during attach.

On the other hand a new binding for the parent would make it more
clear. I wouldn't mind.

>
> > In any case, it means that the provider needs to manage runtime PM,
> > etc for its struct device to not prevent the parent domain from being
> > powered off.
>
> Shouldn't all drivers for devices that can be somewhere in a PM Domain
> hierarchy do that anyway? :-) See e.g. commit 3a611e26e958b037
> ("net/smsc911x: Add minimal runtime PM support").
>
> If "simple-bus" would do that, we could get rid of "simple-pm-bus"...

Right, I totally forgot about that. Thanks for reminding me.

As I said in the other thread, let's drop this patch for now.

Kind regards
Uffe