Re: [RFC/RFT PATCH] PM: sleep: Ignore device driver suspend() callback return values

From: Alan Stern
Date: Thu Dec 05 2024 - 12:54:57 EST


On Thu, Dec 05, 2024 at 12:24:29PM -0500, Len Brown wrote:
> On Thu, Dec 5, 2024 at 10:09 AM Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
>
> > > IMV, drivers returning errors from their suspend callbacks without a
> > > sufficiently serious reason are kind of a problem.
> >
> > There is a least one driver whose suspend callback returns an error if
> > the device is enabled for wakeup and a wakeup event occurs during the
> > suspend procedure. We don't want to ignore those races.
>
> That driver should invoke pm_system_wakeup() on that wakeup event, right?

Should it? When the system isn't yet suspended? Is this documented
anywhere?

There's still a race. Suppose a wakeup-enabled device signals an
interrupt and the interrupt handler runs just before the suspend-resume
transition begins. The handler might end up calling pm_system_wakeup()
before the suspend starts, which won't accomplish anything, while the
work queue that takes care of the device's events might get frozen (as
part of the suspend transition) before it handles the new request. As a
result, the wakeup event will remain in limbo, not aborting the suspend,
not causing an immediate resume, and not getting handled until something
else wakes up the system.

Alan Stern