Re: [PATCH RFC] PM: sleep: Return -ECANCELED if aborting due to pm_wakeup_pending()

Nícolas "F. R. A. Prado" <[email protected]> Tue, 21 Jul 2026 17:25:53 -0300
Newsgroups dev.linux.lists.driver-core,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pm
Message-ID <[email protected]>
On Tue, 2026-06-09 at 08:48 -0400, Nícolas F. R. A. Prado wrote:
> If system sleep (suspend or hibernate) has been aborted due to
> pm_wakeup_pending() returning true, return -ECANCELED so userspace
> can
> tell it apart from actual failures.
> 
> ECANCELED is chosen both because it is a less common error code, so
> it is less likely to be used for purposes other than the sleep abort
> due
> to pending wakeups in this code path, and also because it more
> clearly
> represents that the sleep was intentionally canceled.
> 
> Signed-off-by: Nícolas F. R. A. Prado <[email protected]>
> ---
> To give more context on my specific use case:
> 
> I want to address the situation where the system is running systemd's
> suspend-then-hibernate and while going into hibernation, the user
> triggers a wakeup (by pressing the power button). The expectation is
> that the system would abort suspend-then-hibernate and wakeup, but
> instead it considers that as a hibernation failure and falls back to
> suspend instead. The key thing here is that systemd isn't able to
> tell
> that this hibernation failure is not really a failure but an
> intentional
> abort, which is where the consistent error code for
> pm_wakeup_pending()
> can solve the problem.
> 
> Sending as an RFC as this is changing an ABI and although I'm not
> aware
> of userspace that relies on the current error codes, it would be good
> to
> get more input on this.

Hi,

Any feedback on this RFC?

-- 
Thanks,

Nícolas