diff options
Diffstat (limited to 'drivers/firmware/efi/reboot.c')
| -rw-r--r-- | drivers/firmware/efi/reboot.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/firmware/efi/reboot.c b/drivers/firmware/efi/reboot.c index 62ead9b9d871..ceae84c19d22 100644 --- a/drivers/firmware/efi/reboot.c +++ b/drivers/firmware/efi/reboot.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2014 Intel Corporation; author Matt Fleming * Copyright (c) 2014 Red Hat, Inc., Mark Salter <msalter@redhat.com> @@ -5,6 +6,8 @@ #include <linux/efi.h> #include <linux/reboot.h> +static struct sys_off_handler *efi_sys_off_handler; + int efi_reboot_quirk_mode = -1; void efi_reboot(enum reboot_mode reboot_mode, const char *__unused) @@ -12,7 +15,7 @@ void efi_reboot(enum reboot_mode reboot_mode, const char *__unused) const char *str[] = { "cold", "warm", "shutdown", "platform" }; int efi_mode, cap_reset_mode; - if (!efi_enabled(EFI_RUNTIME_SERVICES)) + if (!efi_rt_services_supported(EFI_RT_SUPPORTED_RESET_SYSTEM)) return; switch (reboot_mode) { @@ -48,18 +51,27 @@ bool __weak efi_poweroff_required(void) return false; } -static void efi_power_off(void) +static int efi_power_off(struct sys_off_data *data) { efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL); + + return NOTIFY_DONE; } static int __init efi_shutdown_init(void) { - if (!efi_enabled(EFI_RUNTIME_SERVICES)) + if (!efi_rt_services_supported(EFI_RT_SUPPORTED_RESET_SYSTEM)) return -ENODEV; - if (efi_poweroff_required()) - pm_power_off = efi_power_off; + if (efi_poweroff_required()) { + /* SYS_OFF_PRIO_FIRMWARE + 1 so that it runs before acpi_power_off */ + efi_sys_off_handler = + register_sys_off_handler(SYS_OFF_MODE_POWER_OFF, + SYS_OFF_PRIO_FIRMWARE + 1, + efi_power_off, NULL); + if (IS_ERR(efi_sys_off_handler)) + return PTR_ERR(efi_sys_off_handler); + } return 0; } |
