Return-Path: Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:54611 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752905AbbEEQPU (ORCPT ); Tue, 5 May 2015 12:15:20 -0400 Message-ID: <1430842506.4113.228.camel@decadent.org.uk> Subject: Re: [stable] x86/reboot: Add EFI reboot quirk for ACPI Hardware Reduced flag From: Ben Hutchings To: Luis Henriques Cc: Matt Fleming , stable Date: Tue, 05 May 2015 17:15:06 +0100 In-Reply-To: <20150505154130.GB2700@ares.olymp> References: <1430703230.4113.156.camel@decadent.org.uk> <1430738423.2724.11.camel@intel.com> <1430746492.4113.158.camel@decadent.org.uk> <20150505091004.GB1769@ares.olymp> <20150505142900.GA2700@ares.olymp> <1430837999.4113.219.camel@decadent.org.uk> <20150505154130.GB2700@ares.olymp> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-9UQ2WeMpACqHjxY0PXUL" Mime-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: --=-9UQ2WeMpACqHjxY0PXUL Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 2015-05-05 at 16:41 +0100, Luis Henriques wrote: > On Tue, May 05, 2015 at 03:59:59PM +0100, Ben Hutchings wrote: > > On Tue, 2015-05-05 at 15:29 +0100, Luis Henriques wrote: > > > On Tue, May 05, 2015 at 10:10:04AM +0100, Luis Henriques wrote: > > > > On Mon, May 04, 2015 at 02:34:52PM +0100, Ben Hutchings wrote: > > > > > On Mon, 2015-05-04 at 12:20 +0100, Matt Fleming wrote: > > > > > > On Mon, 2015-05-04 at 02:33 +0100, Ben Hutchings wrote: > > > > > > > Would this be a sensible addition to 3.16-stable or any older= stable > > > > > > > branch? > > > > > > >=20 > > > > > > > commit 44be28e9dd9880dca3e2cbf7a844f2114e67f2cb > > > > > > > Author: Matt Fleming > > > > > > > Date: Fri Jun 13 12:39:55 2014 +0100 > > > > > > >=20 > > > > > > > x86/reboot: Add EFI reboot quirk for ACPI Hardware Reduce= d flag > > > > > >=20 > > > > > > I'm not sure what the support for ACPI hardware-reduced platfor= ms (ASUS > > > > > > T100, etc) is like in the stable releases but if it does exist = then yeah > > > > > > you probably want the above commit. The above commit should be = a pretty > > > > > > low-risk change. > > > > >=20 > > > > > I understand that the Asus T100 at least is mostly working under = 3.16. > > > > >=20 > > > > > > Be sure to also include commit 8562c99cdd30 ("efi/reboot: Add g= eneric > > > > > > wrapper around EfiResetSystem()") and commit 0c5ed61adbdb ("efi= /reboot: > > > > > > Allow powering off machines using EFI"). > > > > >=20 > > >=20 > > > Ok, it looks like the easy approach to bring this into 3.16 is to pic= k > > > the following commits (in this order): > > >=20 > > > eeb9db09f738 x86/efi: Move all workarounds to a separate file quirk= s.c > > > 8562c99cdd30 efi/reboot: Add generic wrapper around EfiResetSystem(= ) > > > 0c5ed61adbdb efi/reboot: Allow powering off machines using EFI > > > 44be28e9dd98 x86/reboot: Add EFI reboot quirk for ACPI Hardware Red= uced flag > > >=20 > > > All of these are clean cherry-picks (except for the last one that > > > needs same really small context adjustment). If there's no objection= , > > > I'll be sending this out for review shortly. > >=20 > > The first one is really too big according to stable rules. Sorry I > > raised this; I didn't realise there were all these dependencies. >=20 > True, that commit simply moves code around but it's still huge. >=20 > Anyway, a different approach would be to backport 44be28e9dd98 by > moving the changes done to quirks.c into efi.c. I'm attaching a > (just compile tested) backport bellow. >=20 > Obviously, the 2 other commits are still required i.e. we're only > dropping eeb9db09f738 ("x86/efi: Move all workarounds to a separate > file quirks.c"). That would be my personal preference. Ben. > Cheers, > -- > Lu=C3=ADs >=20 > From 41aaf1bdee7e9423a35aee310703111eef96b6b3 Mon Sep 17 00:00:00 2001 > From: Matt Fleming > Date: Fri, 13 Jun 2014 12:39:55 +0100 > Subject: [PATCH] x86/reboot: Add EFI reboot quirk for ACPI Hardware Reduc= ed > flag >=20 > commit 44be28e9dd9880dca3e2cbf7a844f2114e67f2cb upstream. >=20 > It appears that the BayTrail-T class of hardware requires EFI in order > to powerdown and reboot and no other reliable method exists. >=20 > This quirk is generally applicable to all hardware that has the ACPI > Hardware Reduced bit set, since usually ACPI would be the preferred > method. >=20 > Cc: Len Brown > Cc: Mark Salter > Cc: "Rafael J. Wysocki" > Signed-off-by: Matt Fleming > Cc: Ben Hutchings > [ luis: backported to 3.16: > - move changes from quirks.c into efi.c > - adjusted context ] > Signed-off-by: Luis Henriques > --- > arch/x86/include/asm/efi.h | 7 +++++++ > arch/x86/kernel/reboot.c | 18 ++++++++++++++++-- > arch/x86/platform/efi/efi.c | 23 +++++++++++++++++++++++ > drivers/firmware/efi/reboot.c | 8 ++++++++ > include/linux/efi.h | 1 + > 5 files changed, 55 insertions(+), 2 deletions(-) >=20 > diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h > index 1eb5f6433ad8..81396a9a9277 100644 > --- a/arch/x86/include/asm/efi.h > +++ b/arch/x86/include/asm/efi.h > @@ -156,6 +156,9 @@ static inline efi_status_t efi_thunk_set_virtual_addr= ess_map( > return EFI_SUCCESS; > } > #endif /* CONFIG_EFI_MIXED */ > + > +extern bool efi_reboot_required(void); > + > #else > /* > * IF EFI is not configured, have the EFI calls return -ENOSYS. > @@ -168,6 +171,10 @@ static inline efi_status_t efi_thunk_set_virtual_add= ress_map( > #define efi_call5(_f, _a1, _a2, _a3, _a4, _a5) (-ENOSYS) > #define efi_call6(_f, _a1, _a2, _a3, _a4, _a5, _a6) (-ENOSYS) > static inline void parse_efi_setup(u64 phys_addr, u32 data_len) {} > +static inline bool efi_reboot_required(void) > +{ > + return false; > +} > #endif /* CONFIG_EFI */ > =20 > #endif /* _ASM_X86_EFI_H */ > diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c > index 7c138543c500..587be13be0be 100644 > --- a/arch/x86/kernel/reboot.c > +++ b/arch/x86/kernel/reboot.c > @@ -28,6 +28,7 @@ > #include > #include > #include > +#include > =20 > /* > * Power off function, if any > @@ -411,12 +412,25 @@ static struct dmi_system_id __initdata reboot_dmi_t= able[] =3D { > =20 > static int __init reboot_init(void) > { > + int rv; > + > /* > * Only do the DMI check if reboot_type hasn't been overridden > * on the command line > */ > - if (reboot_default) > - dmi_check_system(reboot_dmi_table); > + if (!reboot_default) > + return 0; > + > + /* > + * The DMI quirks table takes precedence. If no quirks entry > + * matches and the ACPI Hardware Reduced bit is set, force EFI > + * reboot. > + */ > + rv =3D dmi_check_system(reboot_dmi_table); > + > + if (!rv && efi_reboot_required()) > + reboot_type =3D BOOT_EFI; > + > return 0; > } > core_initcall(reboot_init); > diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c > index 87fc96bcc13c..53a324606d11 100644 > --- a/arch/x86/platform/efi/efi.c > +++ b/arch/x86/platform/efi/efi.c > @@ -44,6 +44,7 @@ > #include > #include > #include > +#include > =20 > #include > #include > @@ -1340,3 +1341,25 @@ void __init efi_apply_memmap_quirks(void) > if (is_uv_system()) > set_bit(EFI_OLD_MEMMAP, &efi.flags); > } > + > +/* > + * For most modern platforms the preferred method of powering off is via > + * ACPI. However, there are some that are known to require the use of > + * EFI runtime services and for which ACPI does not work at all. > + * > + * Using EFI is a last resort, to be used only if no other option > + * exists. > + */ > +bool efi_reboot_required(void) > +{ > + if (!acpi_gbl_reduced_hardware) > + return false; > + > + efi_reboot_quirk_mode =3D EFI_RESET_WARM; > + return true; > +} > + > +bool efi_poweroff_required(void) > +{ > + return !!acpi_gbl_reduced_hardware; > +} > diff --git a/drivers/firmware/efi/reboot.c b/drivers/firmware/efi/reboot.= c > index e9eeeb3c6345..9c59d1c795d1 100644 > --- a/drivers/firmware/efi/reboot.c > +++ b/drivers/firmware/efi/reboot.c > @@ -5,6 +5,8 @@ > #include > #include > =20 > +int efi_reboot_quirk_mode =3D -1; > + > void efi_reboot(enum reboot_mode reboot_mode, const char *__unused) > { > int efi_mode; > @@ -22,6 +24,12 @@ void efi_reboot(enum reboot_mode reboot_mode, const ch= ar *__unused) > break; > } > =20 > + /* > + * If a quirk forced an EFI reset mode, always use that. > + */ > + if (efi_reboot_quirk_mode !=3D -1) > + efi_mode =3D efi_reboot_quirk_mode; > + > efi.reset_system(efi_mode, EFI_SUCCESS, 0, NULL); > } > =20 > diff --git a/include/linux/efi.h b/include/linux/efi.h > index 2539aff31808..b3fac7c1656c 100644 > --- a/include/linux/efi.h > +++ b/include/linux/efi.h > @@ -876,6 +876,7 @@ extern void efi_reserve_boot_services(void); > extern int efi_get_fdt_params(struct efi_fdt_params *params, int verbose= ); > extern struct efi_memory_map memmap; > =20 > +extern int efi_reboot_quirk_mode; > extern bool efi_poweroff_required(void); > =20 > /* Iterate through an efi_memory_map */ --=20 Ben Hutchings Once a job is fouled up, anything done to improve it makes it worse. --=-9UQ2WeMpACqHjxY0PXUL Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIVAwUAVUjsj+e/yOyVhhEJAQrUWg//WlkhXJ9FmZLAW2H5hGqsE+MLV/WEKVT/ qjMqyLoCalfKWUf2cSPkAW7YvY1iz7ItQvMquWOI9IQyRHYfXZqM5qPIjGDXKlXO jL/tyBUmdJa9RAZC/z3xqlkLUAQZ5B2dBsAcLylL//hTOaJi0TcTwWHYNUNQEnJO dHtg8iPDmPHjxUUi2b/TOPl5fRPzJ+grHuNCgfmSWDYY+JcvwNrIgu/Ky+/5tZ3B Iita6HEXdkiiFmXqXBs1EHUvwjvZRIjO9M2sudb7/e1qCNba96naCUSxjkcpWatA qcFRbTHlkskxawMrP/ujW72gzF4tZ3BRHWDR5fLSBvSI6qdASbUr7eLbzku4rIYm aSzeWrcln3HQltC+Kysix/O23DtoSiaI4KcrkQSWFPIESFlnIxWUV/0fWe4XAxQI 4RRrctYK/+jH+t2WQWiAuhI6ur74Bbibr8w8nIEIFM79+qup0L13igUmpbjtDse1 uQWjN3zJj+xF+m5ATMnSO1rhQnfVPGnQAxPWQDzMBPQpldDH4FdsTlkfzoOSDVZ5 m6IK9KpO9zIpJCvFqqrhPE4fema1PErG3OQlabF+8FSIpPAoU5Pv6j6gOHfw6SfX 2lVSfNZMr7N/7wlugxl5FtUs0rlhCbVrkbrrXULi71FrkdUFx05TcInnNeghHW1K 9lPJ2Qb9fS8= =qkb+ -----END PGP SIGNATURE----- --=-9UQ2WeMpACqHjxY0PXUL--