[v2] PM: suspend: Set mem_sleep_current during kernel command line setup

Message ID 20240229-suspend_ops_late_init-v2-1-34852c61a5fa@quicinc.com
State New
Headers
Series [v2] PM: suspend: Set mem_sleep_current during kernel command line setup |

Commit Message

Maulik Shah Feb. 29, 2024, 6:44 a.m. UTC
  psci_init_system_suspend() invokes suspend_set_ops() very early during
bootup even before kernel command line for mem_sleep_default is setup.
This leads to kernel command line mem_sleep_default=s2idle not working
as mem_sleep_current gets changed to deep via suspend_set_ops() and never
changes back to s2idle.

Set mem_sleep_current along with mem_sleep_default during kernel command
line setup as default suspend mode.

Fixes: faf7ec4a92c0 ("drivers: firmware: psci: add system suspend support")
CC: stable@vger.kernel.org # 5.4+
Signed-off-by: Maulik Shah <quic_mkshah@quicinc.com>
---
Changes in v2:
- Set mem_sleep_current during mem_sleep_default kernel command line setup
- Update commit message accordingly
- Retain Fixes: tag
- Link to v1: https://lore.kernel.org/r/20240219-suspend_ops_late_init-v1-1-6330ca9597fa@quicinc.com
---
 kernel/power/suspend.c | 1 +
 1 file changed, 1 insertion(+)


---
base-commit: d37e1e4c52bc60578969f391fb81f947c3e83118
change-id: 20240219-suspend_ops_late_init-27fb0b15baee

Best regards,
  

Comments

Rafael J. Wysocki Feb. 29, 2024, 7:34 p.m. UTC | #1
On Thu, Feb 29, 2024 at 7:45 AM Maulik Shah <quic_mkshah@quicinc.com> wrote:
>
> psci_init_system_suspend() invokes suspend_set_ops() very early during
> bootup even before kernel command line for mem_sleep_default is setup.
> This leads to kernel command line mem_sleep_default=s2idle not working
> as mem_sleep_current gets changed to deep via suspend_set_ops() and never
> changes back to s2idle.
>
> Set mem_sleep_current along with mem_sleep_default during kernel command
> line setup as default suspend mode.
>
> Fixes: faf7ec4a92c0 ("drivers: firmware: psci: add system suspend support")
> CC: stable@vger.kernel.org # 5.4+
> Signed-off-by: Maulik Shah <quic_mkshah@quicinc.com>
> ---
> Changes in v2:
> - Set mem_sleep_current during mem_sleep_default kernel command line setup
> - Update commit message accordingly
> - Retain Fixes: tag
> - Link to v1: https://lore.kernel.org/r/20240219-suspend_ops_late_init-v1-1-6330ca9597fa@quicinc.com
> ---
>  kernel/power/suspend.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
> index 742eb26618cc..e3ae93bbcb9b 100644
> --- a/kernel/power/suspend.c
> +++ b/kernel/power/suspend.c
> @@ -192,6 +192,7 @@ static int __init mem_sleep_default_setup(char *str)
>                 if (mem_sleep_labels[state] &&
>                     !strcmp(str, mem_sleep_labels[state])) {
>                         mem_sleep_default = state;
> +                       mem_sleep_current = state;
>                         break;
>                 }
>
>
> ---

Applied as 6.9 material, thanks!
  
Dhruva Gole March 1, 2024, 5:43 a.m. UTC | #2
Hi,

On Feb 29, 2024 at 12:14:59 +0530, Maulik Shah wrote:
> psci_init_system_suspend() invokes suspend_set_ops() very early during
> bootup even before kernel command line for mem_sleep_default is setup.
> This leads to kernel command line mem_sleep_default=s2idle not working
> as mem_sleep_current gets changed to deep via suspend_set_ops() and never
> changes back to s2idle.
> 
> Set mem_sleep_current along with mem_sleep_default during kernel command
> line setup as default suspend mode.
> 
> Fixes: faf7ec4a92c0 ("drivers: firmware: psci: add system suspend support")
> CC: stable@vger.kernel.org # 5.4+
> Signed-off-by: Maulik Shah <quic_mkshah@quicinc.com>
> ---
> Changes in v2:
> - Set mem_sleep_current during mem_sleep_default kernel command line setup
> - Update commit message accordingly
> - Retain Fixes: tag
> - Link to v1: https://lore.kernel.org/r/20240219-suspend_ops_late_init-v1-1-6330ca9597fa@quicinc.com
> ---
>  kernel/power/suspend.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
> index 742eb26618cc..e3ae93bbcb9b 100644
> --- a/kernel/power/suspend.c
> +++ b/kernel/power/suspend.c
> @@ -192,6 +192,7 @@ static int __init mem_sleep_default_setup(char *str)
>  		if (mem_sleep_labels[state] &&
>  		    !strcmp(str, mem_sleep_labels[state])) {
>  			mem_sleep_default = state;
> +			mem_sleep_current = state;

I could've missed this patch. Please CC people who are involved in
the previous discussions :)

Reviewed-by: Dhruva Gole <d-gole@ti.com>
  

Patch

diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 742eb26618cc..e3ae93bbcb9b 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -192,6 +192,7 @@  static int __init mem_sleep_default_setup(char *str)
 		if (mem_sleep_labels[state] &&
 		    !strcmp(str, mem_sleep_labels[state])) {
 			mem_sleep_default = state;
+			mem_sleep_current = state;
 			break;
 		}