ACPI / PM: Fix poweroff issue on HW-full platforms without _S5
RFC PATCH v3 1/1 ACPI / PM: Fix poweroff issue on HW-full platforms without _S5
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.
---
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(-)
arch/x86/platform/efi/quirks.c +1 -1
@@ -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); }
drivers/acpi/sleep.c +8 -0
@@ -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 ;
include/linux/acpi.h +1 -0
@@ -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 ) {
Signature · 1 line
1.8.4.2
Rafael J. Wysocki
maintainerQuoted 34 lines · Chen Yu
The problem is Linux registers
pm_power_off=efi_power_offonly 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_S5object.This patch fixes this issue by introducing a new flag
acpi_no_s5which indicates the non-existence of_S5. The initial state ofacpi_no_s5is false and probed inacpi_sleep_init, then we'll later see the updated value inefi_poweroff_required, according to which we can setpm_power_offtoefi_power_offinefi_shutdown_init, if no otherpm_power_offavailable.Suggested-by Len Brown <[email protected]>Signed-off-by Chen Yu <[email protected]>---
v3:
- Only assignpm_power_offtoefi_power_offwhen there are no otherpm_power_offregistered at that time, in case other commponents would like to customize their own implementation.
---
v2:
- Convert theacpi_no_s5to a global bool variable insleep.cand add a declaration toinclude/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(-)arch/x86/platform/efi/quirks.c +0
-0
arch/x86/platform/efi/quirks.c bool efi_reboot_required(void) · line 298
Quoted 5 lines
arch/x86/platform/efi/quirks.c +1
-1@@ -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?
arch/x86/platform/efi/quirks.c bool efi_reboot_required(void) · line 299
Quoted 1 line
arch/x86/platform/efi/quirks.c +0
-0}
Thanks,
Rafael
Hi Rafael,
Quoted 48 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Rafael J. Wysocki
Sent: Monday, March 07, 2016 9:19 PM
To: Chen, Yu C
Cc: ACPI Devel Maling List; [email protected]; [email protected]; Linux Kernel Mailing List; [email protected]; 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_S5Quoted 11 lines · Chen Yu
The problem is Linux registers
pm_power_off=efi_power_offonly 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_S5object.This patch fixes this issue by introducing a new flag
acpi_no_s5which indicates the non-existence of_S5. The initial state ofacpi_no_s5is false and probed inacpi_sleep_init, then we'll later see the updated value inefi_poweroff_required, according to which we can setpm_power_offtoefi_power_offinefi_shutdown_init, if no other
pm_power_offavailable.Quoted 24 lines
Suggested-by Len Brown <[email protected]>Signed-off-by Chen Yu <[email protected]>---
v3:
- Only assignpm_power_offtoefi_power_offwhen there are no otherpm_power_offregistered at that time, in case other commponents would like to customize their own implementation.
---
v2:
- Convert theacpi_no_s5to a global bool variable insleep.cand add a declaration toinclude/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(-)(quoted diff) +0
-0
b/arch/x86/platform/efi/quirks.cindex 2d66db8..0d4186b 100644arch/x86/platform/efi/quirks.c +0
-0@@ -295,5 +295,5 @@ bool efi_reboot_required(void)
Quoted 8 lines
arch/x86/platform/efi/quirks.c bool efi_reboot_required(void)
Quoted 5 lines
arch/x86/platform/efi/quirks.c +2
-1bool efi_poweroff_required (void ) { -return !!acpi_gbl_reduced_hardware; +return acpi_gbl_reduced_hardware || (acpi_no_s5 && + !pm_power_off);What if
CONFIG_ACPIis not set here?
If CONFIG_ACPI is not set, this file would not be compiled, because CONFIG_EFI depends on CONFIG_ACPI.
Hi Rafael,
(resend for broken content)
Quoted 11 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Rafael J. Wysocki
Sent: Monday, March 07, 2016 9:19 PM
To: Chen, Yu C
Cc: ACPI Devel Maling List; [email protected]; [email protected]; Linux Kernel Mailing List; [email protected]; 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]
Quoted 7 lines
Review
Quoted 5 lines
bool
efi_poweroff_required(void)
{(quoted diff) +2
-1- return !!acpi_gbl_reduced_hardware; + return acpi_gbl_reduced_hardware || (acpi_no_s5 && + !pm_power_off);What if
CONFIG_ACPIis not set here?
If CONFIG_ACPI is not set, this file would not be compiled, because CONFIG_EFI depends on CONFIG_ACPI.
thanks,
yu
Quoted 21 lines · Yu C
Hi Rafael,
(resend for broken content)Quoted 11 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Rafael J. Wysocki
Sent: Monday, March 07, 2016 9:19 PM
To: Chen, Yu C
Cc: ACPI Devel Maling List; [email protected]; [email protected]; Linux Kernel Mailing List; [email protected]; 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]
Quoted 6 lines
Quoted 5 lines
bool
efi_poweroff_required(void)
{(quoted diff) +2
-1- return !!acpi_gbl_reduced_hardware; + return acpi_gbl_reduced_hardware || (acpi_no_s5 && + !pm_power_off);
Quoted 3 lines
Quoted 1 line
What if
CONFIG_ACPIis not set here?If
CONFIG_ACPIis not set, this file would not be compiled, becauseCONFIG_EFIdepends onCONFIG_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
Quoted 35 lines
-----Original Message-----
From: [email protected] [mailto:linux-pm- [email protected]] 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; [email protected]; linux- [email protected]; Linux Kernel Mailing List; [email protected]; 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_S5Quoted 22 lines · Yu C
Hi Rafael,
(resend for broken content)Quoted 12 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Rafael J. Wysocki
Sent: Monday, March 07, 2016 9:19 PM
To: Chen, Yu C
Cc: ACPI Devel Maling List; [email protected]; [email protected]; Linux Kernel Mailing List; [email protected]; 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]
Quoted 6 lines
Quoted 5 lines
bool
efi_poweroff_required(void)
{(quoted diff) +2
-1- return !!acpi_gbl_reduced_hardware; + return acpi_gbl_reduced_hardware || (acpi_no_s5 && + !pm_power_off);
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
What if
CONFIG_ACPIis not set here?If
CONFIG_ACPIis not set, this file would not be compiled, becauseCONFIG_EFIdepends onCONFIG_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
Quoted 71 lines · Yu C
Quoted 35 lines
-----Original Message-----
From: [email protected] [mailto:linux-pm- [email protected]] 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; [email protected]; linux- [email protected]; Linux Kernel Mailing List; [email protected]; 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_S5Quoted 22 lines · Yu C
Hi Rafael,
(resend for broken content)Quoted 12 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Rafael J. Wysocki
Sent: Monday, March 07, 2016 9:19 PM
To: Chen, Yu C
Cc: ACPI Devel Maling List; [email protected]; [email protected]; Linux Kernel Mailing List; [email protected]; 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]
Quoted 6 lines
Quoted 5 lines
bool
efi_poweroff_required(void)
{(quoted diff) +2
-1- return !!acpi_gbl_reduced_hardware; + return acpi_gbl_reduced_hardware || (acpi_no_s5 && + !pm_power_off);Quoted 8 lines
Quoted 3 lines
Quoted 1 line
What if
CONFIG_ACPIis not set here?If
CONFIG_ACPIis not set, this file would not be compiled, becauseCONFIG_EFIdepends onCONFIG_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_offmay 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 thepm_power_offtoefi_power_offno matter whether there is_S5or not2. Introduce
/sys/power/poweroff
Allow the user to choose whichpm_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()withreliable_pm_power_off()void
reliable_pm_power_off(void)
Quoted 8 lines
{
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
Quoted 5 lines · Yu C
Hum. unfortunately it is not guaranteed to run after all of the other code, because other components who register
pm_power_offmay 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.
Quoted 22 lines
Currently I'm thinking of 3 possible solutions, could you please give some advices on them:
1. Introduce bootopt of 'poweroff=efi'
Set thepm_power_offtoefi_power_offno matter whether there is_S5or not2. Introduce
/sys/power/poweroff
Allow the user to choose whichpm_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()withreliable_pm_power_off()void
reliable_pm_power_off(void)
Quoted 8 lines
{
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*.
Quoted 97 lines
-----Original Message-----
From: Rafael J. Wysocki [mailto:[email protected]]
Sent: Wednesday, March 09, 2016 6:57 AM
To: Chen, Yu C
Cc: Rafael J. Wysocki; ACPI Devel Maling List; [email protected]; linux- [email protected]; Linux Kernel Mailing List; [email protected]; 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_S5Quoted 35 lines · Yu C
Quoted 35 lines
-----Original Message-----
From: [email protected] [mailto:linux-pm- [email protected]] 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; [email protected]; linux- [email protected]; Linux Kernel Mailing List; [email protected]; 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_S5Quoted 22 lines · Yu C
Hi Rafael,
(resend for broken content)Quoted 13 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Rafael J. Wysocki
Sent: Monday, March 07, 2016 9:19 PM
To: Chen, Yu C
Cc: ACPI Devel Maling List; [email protected]; [email protected]; Linux Kernel Mailing List; [email protected]; 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]
Quoted 5 lines
Quoted 4 lines
bool
efi_poweroff_required(void){(quoted diff) +2
-1- return !!acpi_gbl_reduced_hardware; + return acpi_gbl_reduced_hardware || (acpi_no_s5 && + !pm_power_off);Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
What if
CONFIG_ACPIis not set here?If
CONFIG_ACPIis not set, this file would not be compiled, becauseCONFIG_EFIdepends onCONFIG_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 alternativepower off handling.
Quoted 2 lines
Hum. unfortunately it is not guaranteed to run after all of the other code, because other components who register
pm_power_offmay bebuilt as modules, and
Quoted 5 lines
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:
Quoted 23 lines
1. Introduce bootopt of 'poweroff=efi'
Set thepm_power_offtoefi_power_offno matter whether there is_S5or not2. Introduce
/sys/power/poweroff
Allow the user to choose whichpm_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()withreliable_pm_power_off()void
reliable_pm_power_off(void)Quoted 8 lines
{ if (!pm_power_off) { if (acpi_no_s5) pm_power_off = efi_power_off; /* Other conditions added in the future. */ } pm_power_off(); }
Quoted 2 lines
What about something like adding something like
default_power_offthat would be used bypm_power_offif nothing else is available?
OK, I'll try another version, in which other components can set its default_power_off, then pm_power_off has a chance to be set to default_power_off if pm_power_off is NULL.
Hi Matt,
Quoted 56 lines
-----Original Message-----
From: Matt Fleming [mailto:matt-mF/unelCI9GS6iBeEJttW/[email protected]]
Sent: Wednesday, March 09, 2016 11:35 PM
To: Chen, Yu C
Cc: Rafael J. Wysocki; Rafael J. Wysocki; ACPI Devel Maling List; [email protected]; [email protected]; Linux Kernel Mailing List; linux- [email protected]; 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_S5Quoted 2 lines · Yu C
Hum. unfortunately it is not guaranteed to run after all of the other code, because other components who register
pm_power_offmay bebuilt as modules, and
Quoted 3 lines
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.
Quoted 1 line
Currently I'm thinking of 3 possible solutions, could you please give some
advices on them:
Quoted 23 lines
1. Introduce bootopt of 'poweroff=efi'
Set thepm_power_offtoefi_power_offno matter whether there is_S5or not2. Introduce
/sys/power/poweroff
Allow the user to choose whichpm_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()withreliable_pm_power_off()void
reliable_pm_power_off(void)Quoted 8 lines
{ if (!pm_power_off) { if (acpi_no_s5) pm_power_off = efi_power_off; /* Other conditions added in the future. */ } pm_power_off(); }
Quoted 6 lines
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
_S5and 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.
Quoted 5 lines
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
_S5is 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