Re: [PATCH v1] PM: Discard runtime_xx() handles using pm_ptr()
From: Raag Jadav
Date: Thu Feb 20 2025 - 07:56:30 EST
On Thu, Feb 20, 2025 at 01:15:19PM +0100, Paul Cercueil wrote:
> Hi Raag,
>
> Le jeudi 20 février 2025 à 13:33 +0530, Raag Jadav a écrit :
> > Discard runtime_xx() handles in RUNTIME_PM_OPS() using pm_ptr() macro
> > and drop unnecessary CONFIG_PM ifdeffery.
>
> So the RUNTIME_PM_OPS() is newer and people should use that, but we're
> not yet at the point where the older SET_RUNTIME_PM_OPS() macro can be
> dropped.
>
> The difference is that in the !CONFIG_PM case, the former will
> reference the suspend/resume functions, but they will be detected as
> dead code; on the other hand, the latter macro won't reference them at
> all. Many drivers still wrap their suspend/resume functions in a #ifdef
> CONFIG_PM to avoid warnings about unused static functions. Therefore if
> you unconditionally force the use of the first macro everywhere, many
> drivers will fail to compile in the !CONFIG_PM case.
>
> As for adding pm_ptr() inside RUNTIME_PM_OPS(), it is unnecesary, as
> the whole pm_ops struct should be referenced through pm_ptr() or
> pm_sleep_ptr() anyway, which means that the whole struct and the
> callback functions will be garbage-collected if PM is disabled.
True. My intent was to garbage collect the runtime handles, atleast until
the users are converted to reference their struct pm_ops through it. I
didn't account for the driver wide CONFIG_PM ifdeffery though.
I guess pm.h has its own learning curve.
Raag