diff mbox

[RFC,v3] ACPI / PM: Fix poweroff issue on HW-full platforms without _S5

Message ID 1457319045-25434-1-git-send-email-yu.c.chen@intel.com (mailing list archive)
State RFC, archived
Headers show

Commit Message

Chen Yu March 7, 2016, 2:50 a.m. UTC
The problem is Linux registers pm_power_off = efi_power_off
only if we are in hardware reduced mode. Actually, what we also
want is to do this when ACPI S5 is simply not supported on
non-legacy platforms. That should handle both the HW reduced mode,
and the HW-full mode where the DSDT fails to supply an _S5 object.

This patch fixes this issue by introducing a new flag acpi_no_s5 which
indicates the non-existence of _S5. The initial state of acpi_no_s5 is
false and probed in acpi_sleep_init, then we'll later see the updated
value in efi_poweroff_required, according to which we can set pm_power_off
to efi_power_off in efi_shutdown_init, if no other pm_power_off available.

Suggested-by: Len Brown <len.brown@intel.com>
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
---
v3:
 - Only assign pm_power_off to efi_power_off when there are no
   other pm_power_off registered at that time, in case other
   commponents would like to customize their own implementation.
---
v2:
 - Convert the acpi_no_s5 to a global bool variable in sleep.c and
   add a declaration to include/linux/acpi.h.
---
 arch/x86/platform/efi/quirks.c | 2 +-
 drivers/acpi/sleep.c           | 8 ++++++++
 include/linux/acpi.h           | 1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

Comments

Rafael J. Wysocki March 7, 2016, 1:19 p.m. UTC | #1
On Mon, Mar 7, 2016 at 3:50 AM, Chen Yu <yu.c.chen@intel.com> wrote:
> The problem is Linux registers pm_power_off = efi_power_off
> only if we are in hardware reduced mode. Actually, what we also
> want is to do this when ACPI S5 is simply not supported on
> non-legacy platforms. That should handle both the HW reduced mode,
> and the HW-full mode where the DSDT fails to supply an _S5 object.
>
> This patch fixes this issue by introducing a new flag acpi_no_s5 which
> indicates the non-existence of _S5. The initial state of acpi_no_s5 is
> false and probed in acpi_sleep_init, then we'll later see the updated
> value in efi_poweroff_required, according to which we can set pm_power_off
> to efi_power_off in efi_shutdown_init, if no other pm_power_off available.
>
> Suggested-by: Len Brown <len.brown@intel.com>
> Signed-off-by: Chen Yu <yu.c.chen@intel.com>
> ---
> v3:
>  - Only assign pm_power_off to efi_power_off when there are no
>    other pm_power_off registered at that time, in case other
>    commponents would like to customize their own implementation.
> ---
> v2:
>  - Convert the acpi_no_s5 to a global bool variable in sleep.c and
>    add a declaration to include/linux/acpi.h.
> ---
>  arch/x86/platform/efi/quirks.c | 2 +-
>  drivers/acpi/sleep.c           | 8 ++++++++
>  include/linux/acpi.h           | 1 +
>  3 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
> index 2d66db8..0d4186b 100644
> --- a/arch/x86/platform/efi/quirks.c
> +++ b/arch/x86/platform/efi/quirks.c
> @@ -295,5 +295,5 @@ bool efi_reboot_required(void)
>
>  bool efi_poweroff_required(void)
>  {
> -       return !!acpi_gbl_reduced_hardware;
> +       return acpi_gbl_reduced_hardware || (acpi_no_s5 && !pm_power_off);

What if CONFIG_ACPI is not set here?

>  }

Thanks,
Rafael
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chen Yu March 7, 2016, 3:49 p.m. UTC | #2
SGkgUmFmYWVsLA0KDQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogcmp3
eXNvY2tpQGdtYWlsLmNvbSBbbWFpbHRvOnJqd3lzb2NraUBnbWFpbC5jb21dIE9uIEJlaGFsZiBP
Zg0KPiBSYWZhZWwgSi4gV3lzb2NraQ0KPiBTZW50OiBNb25kYXksIE1hcmNoIDA3LCAyMDE2IDk6
MTkgUE0NCj4gVG86IENoZW4sIFl1IEMNCj4gQ2M6IEFDUEkgRGV2ZWwgTWFsaW5nIExpc3Q7IHg4
NkBrZXJuZWwub3JnOyBsaW51eC1lZmlAdmdlci5rZXJuZWwub3JnOyBMaW51eA0KPiBLZXJuZWwg
TWFpb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unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chen Yu March 7, 2016, 3:53 p.m. UTC | #3
Hi Rafael,
(resend for broken content)

> -----Original Message-----

> From: rjwysocki@gmail.com [mailto:rjwysocki@gmail.com] On Behalf Of

> Rafael J. Wysocki

> Sent: Monday, March 07, 2016 9:19 PM

> To: Chen, Yu C

> Cc: ACPI Devel Maling List; x86@kernel.org; linux-efi@vger.kernel.org; Linux

> Kernel Mailing List; linux-pm@vger.kernel.org; Rafael J. Wysocki; Len Brown;

> Matt Fleming; Thomas Gleixner; Ingo Molnar; H. Peter Anvin; Zhang, Rui

> Subject: Re: [PATCH][RFC v3] ACPI / PM: Fix poweroff issue on HW-full

> platforms without _S5

> 

[cut]
> >  bool efi_poweroff_required(void)

> >  {

> > -       return !!acpi_gbl_reduced_hardware;

> > +       return acpi_gbl_reduced_hardware || (acpi_no_s5 &&

> > + !pm_power_off);

> 

> What if CONFIG_ACPI is not set here?

If CONFIG_ACPI is not set, this file would not 
be compiled, because CONFIG_EFI depends on CONFIG_ACPI.

thanks,
yu
Rafael J. Wysocki March 8, 2016, 1:53 a.m. UTC | #4
On Monday, March 07, 2016 03:53:13 PM Chen, Yu C wrote:
> Hi Rafael,
> (resend for broken content)
> 
> > -----Original Message-----
> > From: rjwysocki@gmail.com [mailto:rjwysocki@gmail.com] On Behalf Of
> > Rafael J. Wysocki
> > Sent: Monday, March 07, 2016 9:19 PM
> > To: Chen, Yu C
> > Cc: ACPI Devel Maling List; x86@kernel.org; linux-efi@vger.kernel.org; Linux
> > Kernel Mailing List; linux-pm@vger.kernel.org; Rafael J. Wysocki; Len Brown;
> > Matt Fleming; Thomas Gleixner; Ingo Molnar; H. Peter Anvin; Zhang, Rui
> > Subject: Re: [PATCH][RFC v3] ACPI / PM: Fix poweroff issue on HW-full
> > platforms without _S5
> > 
> [cut]
> > >  bool efi_poweroff_required(void)
> > >  {
> > > -       return !!acpi_gbl_reduced_hardware;
> > > +       return acpi_gbl_reduced_hardware || (acpi_no_s5 &&
> > > + !pm_power_off);
> > 
> > What if CONFIG_ACPI is not set here?
> If CONFIG_ACPI is not set, this file would not 
> be compiled, because CONFIG_EFI depends on CONFIG_ACPI.

OK

So the next question will be if efi_poweroff_required() is guaranteed to run
after all of the other code that may register alternative power off handling.

Thanks,
Rafael

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chen Yu March 8, 2016, 4:25 p.m. UTC | #5
> -----Original Message-----

> From: linux-pm-owner@vger.kernel.org [mailto:linux-pm-

> owner@vger.kernel.org] On Behalf Of Rafael J. Wysocki

> Sent: Tuesday, March 08, 2016 9:54 AM

> To: Chen, Yu C

> Cc: Rafael J. Wysocki; ACPI Devel Maling List; x86@kernel.org; linux-

> efi@vger.kernel.org; Linux Kernel Mailing List; linux-pm@vger.kernel.org;

> Len Brown; Matt Fleming; Thomas Gleixner; Ingo Molnar; H. Peter Anvin;

> Zhang, Rui

> Subject: Re: [PATCH][RFC v3] ACPI / PM: Fix poweroff issue on HW-full

> platforms without _S5

> 

> On Monday, March 07, 2016 03:53:13 PM Chen, Yu C wrote:

> > Hi Rafael,

> > (resend for broken content)

> >

> > > -----Original Message-----

> > > From: rjwysocki@gmail.com [mailto:rjwysocki@gmail.com] On Behalf Of

> > > Rafael J. Wysocki

> > > Sent: Monday, March 07, 2016 9:19 PM

> > > To: Chen, Yu C

> > > Cc: ACPI Devel Maling List; x86@kernel.org;

> > > linux-efi@vger.kernel.org; Linux Kernel Mailing List;

> > > linux-pm@vger.kernel.org; Rafael J. Wysocki; Len Brown; Matt

> > > Fleming; Thomas Gleixner; Ingo Molnar; H. Peter Anvin; Zhang, Rui

> > > Subject: Re: [PATCH][RFC v3] ACPI / PM: Fix poweroff issue on

> > > HW-full platforms without _S5

> > >

> > [cut]

> > > >  bool efi_poweroff_required(void)

> > > >  {

> > > > -       return !!acpi_gbl_reduced_hardware;

> > > > +       return acpi_gbl_reduced_hardware || (acpi_no_s5 &&

> > > > + !pm_power_off);

> > >

> > > What if CONFIG_ACPI is not set here?

> > If CONFIG_ACPI is not set, this file would not be compiled, because

> > CONFIG_EFI depends on CONFIG_ACPI.

> 

> OK

> 

> So the next question will be if efi_poweroff_required() is guaranteed to run

> after all of the other code that may register alternative power off handling.

Hum. unfortunately it is not guaranteed to run after all of the other code,
because other components who register pm_power_off may be built as modules, and
we can not predict/control the sequence registration.   So this patch may
break the EFI platforms who use non-efi poweroff due to unstable EFI service
,  not sure if there are any released-products of this kind.

Currently I'm thinking of 3 possible solutions,  could you please give some advices on them:

1. Introduce bootopt of 'poweroff=efi'
     Set the pm_power_off to efi_power_off no matter whether there is _S5 or not

2. Introduce /sys/power/poweroff
    Allow the user to choose which  pm_power_off, for example:
 
# cat /sys/power/poweroff
*acpi		acpi_power_off
efi		efi_power_off	
gpio		gpio_poweroff_do_poweroff
user can echo string to enable which one.

And two APIs:
register_power_off(char *name, power_off func)
unregister_power_off(char *name)  


3. replace all the codes of  pm_power_off() with reliable_pm_power_off()

void reliable_pm_power_off(void)
{
	if (!pm_power_off) {
		if (acpi_no_s5)
			pm_power_off = efi_power_off;
	/* Other conditions added in the future. */
	}
	pm_power_off();
}


thanks,
yu
Rafael J. Wysocki March 8, 2016, 10:56 p.m. UTC | #6
On Tuesday, March 08, 2016 04:25:30 PM Chen, Yu C wrote:
> > -----Original Message-----
> > From: linux-pm-owner@vger.kernel.org [mailto:linux-pm-
> > owner@vger.kernel.org] On Behalf Of Rafael J. Wysocki
> > Sent: Tuesday, March 08, 2016 9:54 AM
> > To: Chen, Yu C
> > Cc: Rafael J. Wysocki; ACPI Devel Maling List; x86@kernel.org; linux-
> > efi@vger.kernel.org; Linux Kernel Mailing List; linux-pm@vger.kernel.org;
> > Len Brown; Matt Fleming; Thomas Gleixner; Ingo Molnar; H. Peter Anvin;
> > Zhang, Rui
> > Subject: Re: [PATCH][RFC v3] ACPI / PM: Fix poweroff issue on HW-full
> > platforms without _S5
> > 
> > On Monday, March 07, 2016 03:53:13 PM Chen, Yu C wrote:
> > > Hi Rafael,
> > > (resend for broken content)
> > >
> > > > -----Original Message-----
> > > > From: rjwysocki@gmail.com [mailto:rjwysocki@gmail.com] On Behalf Of
> > > > Rafael J. Wysocki
> > > > Sent: Monday, March 07, 2016 9:19 PM
> > > > To: Chen, Yu C
> > > > Cc: ACPI Devel Maling List; x86@kernel.org;
> > > > linux-efi@vger.kernel.org; Linux Kernel Mailing List;
> > > > linux-pm@vger.kernel.org; Rafael J. Wysocki; Len Brown; Matt
> > > > Fleming; Thomas Gleixner; Ingo Molnar; H. Peter Anvin; Zhang, Rui
> > > > Subject: Re: [PATCH][RFC v3] ACPI / PM: Fix poweroff issue on
> > > > HW-full platforms without _S5
> > > >
> > > [cut]
> > > > >  bool efi_poweroff_required(void)
> > > > >  {
> > > > > -       return !!acpi_gbl_reduced_hardware;
> > > > > +       return acpi_gbl_reduced_hardware || (acpi_no_s5 &&
> > > > > + !pm_power_off);
> > > >
> > > > What if CONFIG_ACPI is not set here?
> > > If CONFIG_ACPI is not set, this file would not be compiled, because
> > > CONFIG_EFI depends on CONFIG_ACPI.
> > 
> > OK
> > 
> > So the next question will be if efi_poweroff_required() is guaranteed to run
> > after all of the other code that may register alternative power off handling.
> Hum. unfortunately it is not guaranteed to run after all of the other code,
> because other components who register pm_power_off may be built as modules, and
> we can not predict/control the sequence registration.   So this patch may
> break the EFI platforms who use non-efi poweroff due to unstable EFI service
> ,  not sure if there are any released-products of this kind.
> 
> Currently I'm thinking of 3 possible solutions,  could you please give some advices on them:
> 
> 1. Introduce bootopt of 'poweroff=efi'
>      Set the pm_power_off to efi_power_off no matter whether there is _S5 or not
> 
> 2. Introduce /sys/power/poweroff
>     Allow the user to choose which  pm_power_off, for example:
>  
> # cat /sys/power/poweroff
> *acpi		acpi_power_off
> efi		efi_power_off	
> gpio		gpio_poweroff_do_poweroff
> user can echo string to enable which one.
> 
> And two APIs:
> register_power_off(char *name, power_off func)
> unregister_power_off(char *name)  
> 
> 
> 3. replace all the codes of  pm_power_off() with reliable_pm_power_off()
> 
> void reliable_pm_power_off(void)
> {
> 	if (!pm_power_off) {
> 		if (acpi_no_s5)
> 			pm_power_off = efi_power_off;
> 	/* Other conditions added in the future. */
> 	}
> 	pm_power_off();
> }

What about something like adding something like default_power_off that would
be used by pm_power_off if nothing else is available?

Thanks,
Rafael

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Matt Fleming March 9, 2016, 3:34 p.m. UTC | #7
On Tue, 08 Mar, at 04:25:30PM, Chen, Yu C wrote:
> Hum. unfortunately it is not guaranteed to run after all of the other code,
> because other components who register pm_power_off may be built as modules, and
> we can not predict/control the sequence registration.   So this patch may
> break the EFI platforms who use non-efi poweroff due to unstable EFI service
> ,  not sure if there are any released-products of this kind.
 
Certainly the majority of x86 client machines do not use EFI power
off, because it hardly ever functions correctly.

> Currently I'm thinking of 3 possible solutions,  could you please give some advices on them:
> 
> 1. Introduce bootopt of 'poweroff=efi'
>      Set the pm_power_off to efi_power_off no matter whether there is _S5 or not
> 
> 2. Introduce /sys/power/poweroff
>     Allow the user to choose which  pm_power_off, for example:
>  
> # cat /sys/power/poweroff
> *acpi		acpi_power_off
> efi		efi_power_off	
> gpio		gpio_poweroff_do_poweroff
> user can echo string to enable which one.
> 
> And two APIs:
> register_power_off(char *name, power_off func)
> unregister_power_off(char *name)  
> 
> 
> 3. replace all the codes of  pm_power_off() with reliable_pm_power_off()
> 
> void reliable_pm_power_off(void)
> {
> 	if (!pm_power_off) {
> 		if (acpi_no_s5)
> 			pm_power_off = efi_power_off;
> 	/* Other conditions added in the future. */
> 	}
> 	pm_power_off();
> }

Be wary of adding all these control knobs. People just want their
machines to reboot properly without having to mess with boot
parameters.

Let's go back to the start. What prompted this patch? Do Intel have
(or are planning) machines that do not have _S5 and are expected to
use EFI to reset the system? Or is this some new configuration
discussed in the ACPI spec that Linux needs to be support? 

Can we remove the ambiguity and options to force EFI reset if _S5 is
missing? Afterall, that's why the function is called
efi_poweroff_*required*.
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chen Yu March 10, 2016, 2:16 a.m. UTC | #8
PiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBSYWZhZWwgSi4gV3lzb2NraSBb
bWFpbHRvOnJqd0Byand5c29ja2kubmV0XQ0KPiBTZW50OiBXZWRuZXNkYXksIE1hcmNoIDA5LCAy
MDE2IDY6NTcgQU0NCj4gVG86IENoZW4sIFl1IEMNCj4gQ2M6IFJhZmFlbCBKLiBXeXNvY2tpOyBB
Q1BJIERldmVsIE1hbGluZyBMaXN0OyB4ODZAa2VybmVsLm9yZzsgbGludXgtDQo+IGVmaUB2Z2Vy
Lmtlcm5lbC5vcmc7IExpbnV4IEtlcm5lbCBNYWlsaW5nIExpc3Q7IGxpbnV4LXBtQHZnZXIua2Vy
bmVsLm9yZzsNCj4gTGVuIEJyb3duOyBNYXR0IEZsZW1pbmc7IFRob21hcyBHbGVpeG5lcjsgSW5n
byBNb2xuYXI7IEguIFBldGVyIEFudmluOw0KPiBaaGFuZywgUnVpDQo+IFN1YmplY3Q6IFJlOiBb
UEFUQ0hdW1JGQyB2M10gQUNQSSAvIFBNOiBGaXggcG93ZXJvZmYgaXNzdWUgb24gSFctZnVsbA0K
PiBwbGF0Zm9ybXMgd2l0aG91dCBfUzUNCj4gDQo+IE9uIFR1ZXNkYXksIE1hcmNoIDA4LCAyMDE2
IDA0OjI1OjMwIFBNIENoZW4sIFl1IEMgd3JvdGU6DQo+ID4gPiAtLS0tLU9yaWdpbmFsIE1lc3Nh
Z2UtLS0tLQ0KPiA+ID4gRnJvbTogbGludXgtcG0tb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WYgKGFjcGlfbm9fczUpDQo+ID4gCQkJcG1fcG93ZXJfb2ZmID0gZWZpX3Bvd2VyX29mZjsNCj4g
PiAJLyogT3RoZXIgY29uZGl0aW9ucyBhZGRlZCBpbiB0aGUgZnV0dXJlLiAqLw0KPiA+IAl9DQo+
ID4gCXBtX3Bvd2VyX29mZigpOw0KPiA+IH0NCj4gDQo+IFdoYXQgYWJvdXQgc29tZXRoaW5nIGxp
a2UgYWRkaW5nIHNvbWV0aGluZyBsaWtlIGRlZmF1bHRfcG93ZXJfb2ZmIHRoYXQNCj4gd291bGQg
YmUgdXNlZCBieSBwbV9wb3dlcl9vZmYgaWYgbm90aGluZyBlbHNlIGlzIGF2YWlsYWJsZT8NCk9L
LCAgSSdsbCB0cnkgYW5vdGhlciB2ZXJzaW9uLCBpbiB3aGljaCBvdGhlciBjb21wb25lbnRzIGNh
biBzZXQgIGl0cyBkZWZhdWx0X3Bvd2VyX29mZiwNCnRoZW4gcG1fcG93ZXJfb2ZmIGhhcyBhIGNo
YW5jZSB0byBiZSBzZXQgdG8gZGVmYXVsdF9wb3dlcl9vZmYgaWYgcG1fcG93ZXJfb2ZmIGlzIE5V
TEwuDQoNCg0K
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chen Yu March 10, 2016, 2:25 a.m. UTC | #9
Hi Matt,

> -----Original Message-----
> From: Matt Fleming [mailto:matt@codeblueprint.co.uk]
> Sent: Wednesday, March 09, 2016 11:35 PM
> To: Chen, Yu C
> Cc: Rafael J. Wysocki; Rafael J. Wysocki; ACPI Devel Maling List;
> x86@kernel.org; linux-efi@vger.kernel.org; Linux Kernel Mailing List; linux-
> pm@vger.kernel.org; Len Brown; Thomas Gleixner; Ingo Molnar; H. Peter
> Anvin; Zhang, Rui
> Subject: Re: [PATCH][RFC v3] ACPI / PM: Fix poweroff issue on HW-full
> platforms without _S5
> 
> On Tue, 08 Mar, at 04:25:30PM, Chen, Yu C wrote:
> > Hum. unfortunately it is not guaranteed to run after all of the other
> > code, because other components who register pm_power_off may be
> built as modules, and
> > we can not predict/control the sequence registration.   So this patch may
> > break the EFI platforms who use non-efi poweroff due to unstable EFI
> > service ,  not sure if there are any released-products of this kind.
> 
> Certainly the majority of x86 client machines do not use EFI power off,
> because it hardly ever functions correctly.
> 
> > Currently I'm thinking of 3 possible solutions,  could you please give some
> advices on them:
> >
> > 1. Introduce bootopt of 'poweroff=efi'
> >      Set the pm_power_off to efi_power_off no matter whether there is
> > _S5 or not
> >
> > 2. Introduce /sys/power/poweroff
> >     Allow the user to choose which  pm_power_off, for example:
> >
> > # cat /sys/power/poweroff
> > *acpi		acpi_power_off
> > efi		efi_power_off
> > gpio		gpio_poweroff_do_poweroff
> > user can echo string to enable which one.
> >
> > And two APIs:
> > register_power_off(char *name, power_off func)
> > unregister_power_off(char *name)
> >
> >
> > 3. replace all the codes of  pm_power_off() with
> > reliable_pm_power_off()
> >
> > void reliable_pm_power_off(void)
> > {
> > 	if (!pm_power_off) {
> > 		if (acpi_no_s5)
> > 			pm_power_off = efi_power_off;
> > 	/* Other conditions added in the future. */
> > 	}
> > 	pm_power_off();
> > }
> 
> Be wary of adding all these control knobs. People just want their machines to
> reboot properly without having to mess with boot parameters.
> 
> Let's go back to the start. What prompted this patch? Do Intel have (or are
> planning) machines that do not have _S5 and are expected to use EFI to reset
> the system? 
Yes, there might be a new platform without _S5, and might need EFI poweroff
for a backup.
> Or is this some new configuration discussed in the ACPI spec
> that Linux needs to be support?
> 
> Can we remove the ambiguity and options to force EFI reset if _S5 is missing?
> Afterall, that's why the function is called efi_poweroff_*required*.
OK, the boot option is obsoleted, I'll try another version of default_power_off per
Rafael's suggestion, thanks.

yu
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
index 2d66db8..0d4186b 100644
--- a/arch/x86/platform/efi/quirks.c
+++ b/arch/x86/platform/efi/quirks.c
@@ -295,5 +295,5 @@  bool efi_reboot_required(void)
 
 bool efi_poweroff_required(void)
 {
-	return !!acpi_gbl_reduced_hardware;
+	return acpi_gbl_reduced_hardware || (acpi_no_s5 && !pm_power_off);
 }
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 9cb9752..94099a4 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -25,6 +25,12 @@ 
 #include "internal.h"
 #include "sleep.h"
 
+/*
+ * Some HW-full platforms do not have _S5, they may have
+ * to leverage efi rather than acpi for a shutdown, if no
+ * other pm_power_off available.
+ */
+bool acpi_no_s5;
 static u8 sleep_states[ACPI_S_STATE_COUNT];
 
 static void acpi_sleep_tts_switch(u32 acpi_state)
@@ -846,6 +852,8 @@  int __init acpi_sleep_init(void)
 		sleep_states[ACPI_STATE_S5] = 1;
 		pm_power_off_prepare = acpi_power_off_prepare;
 		pm_power_off = acpi_power_off;
+	} else {
+		acpi_no_s5 = true;
 	}
 
 	supported[0] = 0;
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 06ed7e5..4d2e67f 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -278,6 +278,7 @@  void acpi_irq_stats_init(void);
 extern u32 acpi_irq_handled;
 extern u32 acpi_irq_not_handled;
 extern unsigned int acpi_sci_irq;
+extern bool acpi_no_s5;
 #define INVALID_ACPI_IRQ	((unsigned)-1)
 static inline bool acpi_sci_irq_valid(void)
 {