[PATCH v3 05/13] power-domain: Add refcounting

Simon Glass sjg at chromium.org
Mon Jan 20 20:21:04 CET 2025


Hi Miquel,

On Mon, 20 Jan 2025 at 03:34, Miquel Raynal <miquel.raynal at bootlin.com> wrote:
>
> Hello Simon,
>
> >>  int power_domain_on(struct power_domain *power_domain)
> >>  {
>
> ...
>
> >> +       if (priv->on_count++ > 0)
> >> +               return 0;
> >
> > -EALREADY
>
> ...
>
> >>  int power_domain_off(struct power_domain *power_domain)
> >>  {
>
> ...
>
> >> +       if (priv->on_count-- > 1)
> >> +               return 0;
> >
> > -EBUSY
> >
> > See how the regulator uclass does it.
>
> I really does not understand why we would like to do that.
>
> It is perfectly normal operation to call power_domain_on/off() on the
> same power domain several times in a row and there is no reason to
> return an error code. It is quite the opposite, the main reason for
> power domains is to act like shared regulators. Se while a regulator has
> one user and doing the same action on it several times does not make
> much sense and can be reported, that is not how power domains have been
> thought about in the first place.

I am not aware of any difference between these two subsystems. If we
want a power domain to actually turn off, how many times do we need to
call power_domain_off()? The function silently does nothing in many
cases, so it is not deterministic. In the case where we *actually*
want to turn the power domain off, we are at a loss as to what code to
write.

>
> Hence, I do not agree with returning error codes in these situations,
> they are misleading and they would have to be ignored anyway.
>

How about creating a power_domain_off_if_allowed() or
power_domain_soft_off/on() or power_domain_req_off (for request)?

Regards,
SImon


More information about the U-Boot mailing list