mirror-linux/kernel/power
David Woodhouse 3e251afaec arm64: Use SYSTEM_OFF2 PSCI call to power off for hibernate
The PSCI v1.3 specification adds support for a SYSTEM_OFF2 function
which is analogous to ACPI S4 state. This will allow hosting
environments to determine that a guest is hibernated rather than just
powered off, and handle that state appropriately on subsequent launches.

Since commit 60c0d45a7f ("efi/arm64: use UEFI for system reset and
poweroff") the EFI shutdown method is deliberately preferred over PSCI
or other methods. So register a SYS_OFF_MODE_POWER_OFF handler which
*only* handles the hibernation, leaving the original PSCI SYSTEM_OFF as
a last resort via the legacy pm_power_off function pointer.

The hibernation code already exports a system_entering_hibernation()
function which is be used by the higher-priority handler to check for
hibernation. That existing function just returns the value of a static
boolean variable from hibernate.c, which was previously only set in the
hibernation_platform_enter() code path. Set the same flag in the simpler
code path around the call to kernel_power_off() too.

An alternative way to hook SYSTEM_OFF2 into the hibernation code would
be to register a platform_hibernation_ops structure with an ->enter()
method which makes the new SYSTEM_OFF2 call. But that would have the
unwanted side-effect of making hibernation take a completely different
code path in hibernation_platform_enter(), invoking a lot of special dpm
callbacks.

Another option might be to add a new SYS_OFF_MODE_HIBERNATE mode, with
fallback to SYS_OFF_MODE_POWER_OFF. Or to use the sys_off_data to
indicate whether the power off is for hibernation.

But this version works and is relatively simple.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Link: https://lore.kernel.org/r/20241019172459.2241939-7-dwmw2@infradead.org
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
2024-10-31 17:52:13 +00:00
..
Kconfig PM: hibernate: Add support for LZ4 compression for hibernation 2024-02-05 14:30:35 +01:00
Makefile PM: sleep: Narrow down -DDEBUG on kernel/power/ files 2022-04-13 16:34:01 +02:00
autosleep.c
console.c
energy_model.c PM: EM: Add em_dev_update_chip_binning() 2024-04-08 16:05:14 +02:00
hibernate.c arm64: Use SYSTEM_OFF2 PSCI call to power off for hibernate 2024-10-31 17:52:13 +00:00
main.c PM: sleep: Use sysfs_emit() and sysfs_emit_at() in "show" functions 2024-08-02 16:03:51 +02:00
power.h PM: hibernate: Don't ignore return from set_memory_ro() 2024-02-22 20:08:03 +01:00
poweroff.c tty: sysrq: switch sysrq handlers from int to u8 2023-07-25 19:21:03 +02:00
process.c cgroup/cpuset: Make cpuset hotplug processing synchronous 2024-04-08 07:39:16 -10:00
qos.c PM: QoS: Add check to make sure CPU latency is non-negative 2023-08-22 21:37:29 +02:00
snapshot.c PM: hibernate: Remove unused stub for saveable_highmem_page() 2024-09-10 20:11:40 +02:00
suspend.c PM: s2idle: Make sure CPUs will wakeup directly on resume 2024-04-08 15:36:54 +02:00
suspend_test.c rtc: class: make rtc_class constant 2024-03-08 12:05:10 +01:00
swap.c mm: remove the implementation of swap_free() and always use swap_free_nr() 2024-07-03 19:30:01 -07:00
user.c [tree-wide] finally take no_llseek out 2024-09-27 08:18:43 -07:00
wakelock.c