summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorMario Limonciello (AMD) <superm1@kernel.org>2026-09-26 17:55:51 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2026-09-30 21:45:39 +0200
commit9df3e4316c2ee861074b631b8a232ae37ce093ab (patch)
tree21a019b8a2e633136340bd3c0ddd2ad527efa8b1 /drivers/base
parent5f1c0e5200da88f9a9abd9be04415e44694131f6 (diff)
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>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/power/main.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 4e0d6357a37c..88a31e09e4f3 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -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;