[PATCH v5 1/2] pm: runtime: Add new devm functions

Rafael J. Wysocki rafael at kernel.org
Thu Mar 27 04:08:39 PDT 2025


On Thu, Mar 27, 2025 at 10:02 AM Csókás Bence <csokas.bence at prolan.hu> wrote:
>
> Hi,
>
> On 2025. 03. 26. 18:38, Rafael J. Wysocki wrote:
> > I said I didn't like it and I'm still not liking it.
>
> You didn't really elaborate further, but now I'm glad I could understand
> your dislike.
>
> > The problem is that the primary role of pm_runtime_set_active() is to
> > prepare the device for enabling runtime PM, so in the majority of
> > cases it should be followed by pm_runtime_enable().  It is also not
> > always necessary to call pm_runtime_set_suspended() after disabling
> > runtime PM for a device, like when the device has been
> > runtime-suspended before disabling runtime PM for it.  This is not
> > like releasing a resource that has been allocated and using devm for
> > it in the above way is at least questionable.
> >
> > Now, there is a reason why calling pm_runtime_set_suspended() on a
> > device after disabling runtime PM for it is a good idea at all.
> > Namely, disabling runtime PM alone does not release the device's
> > suppliers or its parent, so if you want to release them after
> > disabling runtime PM for the device, you need to do something more.
> > I'm thinking that this is a  mistake in the design of the runtime PM
> > core.
>
> Well, this is the order in which the original driver worked before
> anyways. As a quick fix, would it work if we created a devm function
> that would pm_runtime_set_active(), immediately followed by
> pm_runtime_enable(), and on cleanup it would pm_runtime_set_suspended()
> followed by pm_runtime_disable_action() (i.e.
> pm_runtime_dont_use_autosuspend() and pm_runtime_disable())?

On cleanup you'd need to ensure that pm_runtime_disable() is followed
by pm_runtime_set_suspended() (not the other way around).  Also
pm_runtime_dont_use_autosuspend() needs to be called when runtime PM
is still enabled.

With the above taken into account, it would work.



More information about the linux-arm-kernel mailing list