Skip to content

Commit 44be28e

Browse files
author
Matt Fleming
committed
x86/reboot: Add EFI reboot quirk for ACPI Hardware Reduced flag
It appears that the BayTrail-T class of hardware requires EFI in order to powerdown and reboot and no other reliable method exists. This quirk is generally applicable to all hardware that has the ACPI Hardware Reduced bit set, since usually ACPI would be the preferred method. Cc: Len Brown <len.brown@intel.com> Cc: Mark Salter <msalter@redhat.com> Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
1 parent 0c5ed61 commit 44be28e

5 files changed

Lines changed: 54 additions & 2 deletions

File tree

‎arch/x86/include/asm/efi.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ extern struct efi_config *efi_early;
183183
#define efi_call_early(f, ...) \
184184
efi_early->call(efi_early->f, __VA_ARGS__);
185185

186+
extern bool efi_reboot_required(void);
187+
186188
#else
187189
/*
188190
* IF EFI is not configured, have the EFI calls return -ENOSYS.
@@ -195,6 +197,10 @@ extern struct efi_config *efi_early;
195197
#define efi_call5(_f, _a1, _a2, _a3, _a4, _a5) (-ENOSYS)
196198
#define efi_call6(_f, _a1, _a2, _a3, _a4, _a5, _a6) (-ENOSYS)
197199
static inline void parse_efi_setup(u64 phys_addr, u32 data_len) {}
200+
static inline bool efi_reboot_required(void)
201+
{
202+
return false;
203+
}
198204
#endif /* CONFIG_EFI */
199205

200206
#endif /* _ASM_X86_EFI_H */

‎arch/x86/kernel/reboot.c‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/mc146818rtc.h>
2929
#include <asm/realmode.h>
3030
#include <asm/x86_init.h>
31+
#include <asm/efi.h>
3132

3233
/*
3334
* Power off function, if any
@@ -401,12 +402,25 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
401402

402403
static int __init reboot_init(void)
403404
{
405+
int rv;
406+
404407
/*
405408
* Only do the DMI check if reboot_type hasn't been overridden
406409
* on the command line
407410
*/
408-
if (reboot_default)
409-
dmi_check_system(reboot_dmi_table);
411+
if (!reboot_default)
412+
return 0;
413+
414+
/*
415+
* The DMI quirks table takes precedence. If no quirks entry
416+
* matches and the ACPI Hardware Reduced bit is set, force EFI
417+
* reboot.
418+
*/
419+
rv = dmi_check_system(reboot_dmi_table);
420+
421+
if (!rv && efi_reboot_required())
422+
reboot_type = BOOT_EFI;
423+
410424
return 0;
411425
}
412426
core_initcall(reboot_init);

‎arch/x86/platform/efi/quirks.c‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/slab.h>
88
#include <linux/memblock.h>
99
#include <linux/bootmem.h>
10+
#include <linux/acpi.h>
1011
#include <asm/efi.h>
1112
#include <asm/uv/uv.h>
1213

@@ -265,3 +266,25 @@ void __init efi_apply_memmap_quirks(void)
265266
if (is_uv_system())
266267
set_bit(EFI_OLD_MEMMAP, &efi.flags);
267268
}
269+
270+
/*
271+
* For most modern platforms the preferred method of powering off is via
272+
* ACPI. However, there are some that are known to require the use of
273+
* EFI runtime services and for which ACPI does not work at all.
274+
*
275+
* Using EFI is a last resort, to be used only if no other option
276+
* exists.
277+
*/
278+
bool efi_reboot_required(void)
279+
{
280+
if (!acpi_gbl_reduced_hardware)
281+
return false;
282+
283+
efi_reboot_quirk_mode = EFI_RESET_WARM;
284+
return true;
285+
}
286+
287+
bool efi_poweroff_required(void)
288+
{
289+
return !!acpi_gbl_reduced_hardware;
290+
}

‎drivers/firmware/efi/reboot.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <linux/efi.h>
66
#include <linux/reboot.h>
77

8+
int efi_reboot_quirk_mode = -1;
9+
810
void efi_reboot(enum reboot_mode reboot_mode, const char *__unused)
911
{
1012
int efi_mode;
@@ -22,6 +24,12 @@ void efi_reboot(enum reboot_mode reboot_mode, const char *__unused)
2224
break;
2325
}
2426

27+
/*
28+
* If a quirk forced an EFI reset mode, always use that.
29+
*/
30+
if (efi_reboot_quirk_mode != -1)
31+
efi_mode = efi_reboot_quirk_mode;
32+
2533
efi.reset_system(efi_mode, EFI_SUCCESS, 0, NULL);
2634
}
2735

‎include/linux/efi.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,7 @@ extern void efi_reserve_boot_services(void);
878878
extern int efi_get_fdt_params(struct efi_fdt_params *params, int verbose);
879879
extern struct efi_memory_map memmap;
880880

881+
extern int efi_reboot_quirk_mode;
881882
extern bool efi_poweroff_required(void);
882883

883884
/* Iterate through an efi_memory_map */

0 commit comments

Comments
 (0)