Re: [PATCH] alarmtimer, PM: suspend: Expose a function from

From: Thomas Gleixner
Date: Wed Feb 07 2024 - 06:26:41 EST


On Wed, Jan 31 2024 at 21:10, Rafael J. Wysocki wrote:
> On Wed, Jan 31, 2024 at 8:13 PM Pranav Prasad <pranavpp@xxxxxxxxxx> wrote:
>> @@ -564,6 +565,8 @@ static int enter_state(suspend_state_t state)
>> #endif
>> } else if (!valid_state(state)) {
>> return -EINVAL;
>> + } else if (time_check_suspend_fail()) {
>> + return -ETIME;
>
> This causes a function defined in modular code to be called from
> non-modular code which is an obvious mistake.
>
> It also makes the generic suspend code call a function defined in a
> random driver, which is a total no-go as far as I am concerned.

Alarmtimers is built-in core infrastructure and not a random modular
driver, but nevertheless:

> Why don't you instead define a PM notifier in the alarmtimer driver
> and check if it is going to trigger shortly from there? PM notifiers
> run before the tasks freezer, so there would be a little difference
> timing-wise and you can return whatever error code you like from
> there. As an additional benefit, you'd be able to handle hibernation
> in the same way.

Makes sense.

Thanks,

tglx