Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PM: Introduce new PMSG_POWEROFF event

PMSG_POWEROFF will be used for the PM core to allow differentiating between
a hibernation or shutdown sequence 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>
Link: https://patch.msgid.link/20251112224025.2051702-2-superm1@kernel.org
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Mario Limonciello (AMD) and committed by
Rafael J. Wysocki
0ca04993 9cf02802

+10 -1
+5
drivers/base/power/main.c
··· 96 96 return "restore"; 97 97 case PM_EVENT_RECOVER: 98 98 return "recover"; 99 + case PM_EVENT_POWEROFF: 100 + return "poweroff"; 99 101 default: 100 102 return "(unknown PM event)"; 101 103 } ··· 370 368 case PM_EVENT_FREEZE: 371 369 case PM_EVENT_QUIESCE: 372 370 return ops->freeze; 371 + case PM_EVENT_POWEROFF: 373 372 case PM_EVENT_HIBERNATE: 374 373 return ops->poweroff; 375 374 case PM_EVENT_THAW: ··· 405 402 case PM_EVENT_FREEZE: 406 403 case PM_EVENT_QUIESCE: 407 404 return ops->freeze_late; 405 + case PM_EVENT_POWEROFF: 408 406 case PM_EVENT_HIBERNATE: 409 407 return ops->poweroff_late; 410 408 case PM_EVENT_THAW: ··· 440 436 case PM_EVENT_FREEZE: 441 437 case PM_EVENT_QUIESCE: 442 438 return ops->freeze_noirq; 439 + case PM_EVENT_POWEROFF: 443 440 case PM_EVENT_HIBERNATE: 444 441 return ops->poweroff_noirq; 445 442 case PM_EVENT_THAW:
+3
include/linux/pm.h
··· 508 508 * RECOVER Creation of a hibernation image or restoration of the main 509 509 * memory contents from a hibernation image has failed, call 510 510 * ->thaw() and ->complete() for all devices. 511 + * POWEROFF System will poweroff, call ->poweroff() for all devices. 511 512 * 512 513 * The following PM_EVENT_ messages are defined for internal use by 513 514 * kernel subsystems. They are never issued by the PM core. ··· 539 538 #define PM_EVENT_USER 0x0100 540 539 #define PM_EVENT_REMOTE 0x0200 541 540 #define PM_EVENT_AUTO 0x0400 541 + #define PM_EVENT_POWEROFF 0x0800 542 542 543 543 #define PM_EVENT_SLEEP (PM_EVENT_SUSPEND | PM_EVENT_HIBERNATE) 544 544 #define PM_EVENT_USER_SUSPEND (PM_EVENT_USER | PM_EVENT_SUSPEND) ··· 554 552 #define PMSG_QUIESCE ((struct pm_message){ .event = PM_EVENT_QUIESCE, }) 555 553 #define PMSG_SUSPEND ((struct pm_message){ .event = PM_EVENT_SUSPEND, }) 556 554 #define PMSG_HIBERNATE ((struct pm_message){ .event = PM_EVENT_HIBERNATE, }) 555 + #define PMSG_POWEROFF ((struct pm_message){ .event = PM_EVENT_POWEROFF, }) 557 556 #define PMSG_RESUME ((struct pm_message){ .event = PM_EVENT_RESUME, }) 558 557 #define PMSG_THAW ((struct pm_message){ .event = PM_EVENT_THAW, }) 559 558 #define PMSG_RESTORE ((struct pm_message){ .event = PM_EVENT_RESTORE, })
+2 -1
include/trace/events/power.h
··· 179 179 { PM_EVENT_HIBERNATE, "hibernate" }, \ 180 180 { PM_EVENT_THAW, "thaw" }, \ 181 181 { PM_EVENT_RESTORE, "restore" }, \ 182 - { PM_EVENT_RECOVER, "recover" }) 182 + { PM_EVENT_RECOVER, "recover" }, \ 183 + { PM_EVENT_POWEROFF, "poweroff" }) 183 184 184 185 DEFINE_EVENT(cpu, cpu_frequency, 185 186