Re: (subset) [PATCH v2 0/7] Devm helpers for regulator get and enable

From: Mark Brown
Date: Mon Aug 15 2022 - 12:33:27 EST


On Mon, Aug 15, 2022 at 06:54:45PM +0300, Laurent Pinchart wrote:

> - With devres, you don't have full control over the order in which
> resources will be released, which means that you can't control the
> power off sequence, in particular if it needs to be sequenced with
> GPIOs and clocks. That's not a concern for all drivers, but this API
> will creep in in places where it shouldn't be used, driver authours
> should really pay attention to power management and not live with the
> false impression that everything will be handled automatically for
> them. In the worst cases, an incorrect power off sequence could lead
> to hardware damage.

I basically agree with these concerns which is why I was only happy with
this API when Matti suggested doing it in a way that meant that the
callers are unable to access the regulator at runtime, this means that
if anyone wants to do any kind of management of the power state outside
of probe and remove they are forced to convert to the full fat APIs.
The general ordering concern with devm is that the free happens too late
but for the most part this isn't such a concern with regulators, they
might have delayed power off anyway due to sharing - it's no worse than
memory allocation AFAICT. Given all the other APIs using devm it's
probably going to end up fixing some bugs.

For sequencing I'm not convinced it's much worse than the bulk API is
anyway, and practically speaking I expect most devices that have
problems here will also need more control over power anyway - it's
certainly the common case that hardware has pretty basic requirements
and is fairly tolerant.

> - Powering regulators on at probe time and leaving them on is a very bad
> practice from a power management point of view, and should really be
> discouraged. Adding convenience helpers to make this easy is the wrong
> message, we should instead push driver authors to implement proper
> runtime PM.

The stick simply isn't working here as far as I can see.

Attachment: signature.asc
Description: PGP signature