PM: sleep: Add resume event mapping for PMSG_POWEROFF

PM_EVENT_POWEROFF (0x0800) and PMSG_POWEROFF were already defined in
include/linux/pm.h, and pm_op(), pm_late_early_op() and pm_noirq_op()
already dispatch PM_EVENT_POWEROFF to the same ops->poweroff*() callbacks
as PM_EVENT_HIBERNATE.  Add the matching entry to resume_event() so that
when a poweroff suspend sequence is aborted (for example a device's
->poweroff_noirq() callback fails and the PM core rolls the
already-suspended devices back), those devices are resumed with
PMSG_RESTORE and their ->restore*() callbacks run.

Map it to PMSG_RESTORE, mirroring the existing PM_EVENT_HIBERNATE
handling.  This is correct because both events suspend via
ops->poweroff*(), whose counterpart is ops->restore*().  Mapping to
PMSG_ON would be a no-op: it is what the default return already yields,
and pm_op()/pm_late_early_op()/pm_noirq_op() have no PM_EVENT_ON case,
so they would return NULL and silently skip every resume callback on the
abort path.

This completes the PMSG_POWEROFF infrastructure needed to support
differentiating between hibernation and shutdown sequences when
re-using callbacks for common code.

Hibernation is started by writing a hibernation method (such as 'platform'
'shutdown', or 'reboot') to use into /sys/power/disk and writing 'disk' to
/sys/power/state.

Shutdown is initiated with the reboot() syscall with arguments on whether
to halt the system or power it off.

Tested-by: Eric Naim <dnaim@cachyos.org>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
[ rjw: Subject tweak ]
Link: https://patch.msgid.link/20260926225555.2916525-1-mario.limonciello@amd.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
Mario Limonciello (AMD) 2026-09-26 17:55:51 -05:00 committed by Rafael J. Wysocki
parent 5f1c0e5200
commit 9df3e4316c

View File

@ -1482,6 +1482,7 @@ static pm_message_t resume_event(pm_message_t sleep_state)
case PM_EVENT_QUIESCE:
return PMSG_RECOVER;
case PM_EVENT_HIBERNATE:
case PM_EVENT_POWEROFF:
return PMSG_RESTORE;
}
return PMSG_ON;