Skip to contentSkip to conversation

PM / s2idle: Fix the failure of specifying "mem_sleep_default=" parameter

PATCH In review xiongxin 2 participants 3 messages Jul 9, 2021 – Aug 4, 2021

Subsystems (2)
lore
Share & tools
lore

xiongxin

author
#0 lore raw

PATCH 1/1 PM / s2idle: Fix the failure of specifying "mem_sleep_default=" parameter

From: xiongxin <[email protected]>

On the arm64 platform, the psci driver is used by default to set the suspend_ops structure; but the psci_acpi_init() function is called before the command-line parameter "mem_sleep_default=" is specified; the user cannot set the desired suspend mode through the "mem_sleep_default=" parameter;

In mem_sleep_default_setup(), judge whether suspend_ops is set, if it has been assigned, rewrite the value of mem_sleep_current variable; in order to complete the user setting;

kernel/power/suspend.c +15 -0
index d8cae434f9eb..bef4b17de3f6 100644
@@ -192,6 +192,21 @@ static int __init mem_sleep_default_setup(char *str)
 			break;
 		}
 
+	/*
+	 * When the suspend_ops has been set, "mem_sleep_default=*" will
+	 * be invalid, here to fix this situation.
+	 */
+	if (suspend_ops) {
+		if (mem_sleep_default == PM_SUSPEND_TO_IDLE)
+			mem_sleep_current = PM_SUSPEND_TO_IDLE;
+		else if ((mem_sleep_default == PM_SUSPEND_STANDBY) &&
+				valid_state(PM_SUSPEND_STANDBY))
+			mem_sleep_current = PM_SUSPEND_STANDBY;
+		else if ((mem_sleep_default >= PM_SUSPEND_MEM) &&
+				valid_state(PM_SUSPEND_MEM))
+			mem_sleep_current = PM_SUSPEND_MEM;
+	}
+
 	return 1;
 }
 __setup("mem_sleep_default=", mem_sleep_default_setup);
Signature · 1 line
2.25.1
#1 lore raw
Quoted 9 lines · xiongxin

From: xiongxin <[email protected]>

On the arm64 platform, the psci driver is used by default to set the suspend_ops structure; but the psci_acpi_init() function is called before the command-line parameter "mem_sleep_default=" is specified; the user cannot set the desired suspend mode through the "mem_sleep_default=" parameter;

Quoted 5 lines

In mem_sleep_default_setup(), judge whether suspend_ops is set, if it has been assigned, rewrite the value of mem_sleep_current variable; in order to complete the user setting;

It's the third submission of the same patch AFAICS.

Have you made any changes to it since the previous submissions? If not, it is not necessary (or even useful) to resend it.

Quoted 30 lines
kernel/power/suspend.c +15 -1
index d8cae434f9eb..bef4b17de3f6 100644
@@ -192,6 +192,21 @@ static int __init mem_sleep_default_setup(char *str)
                        break;
                }
 
+       /*
+        * When the suspend_ops has been set, "mem_sleep_default=*" will
+        * be invalid, here to fix this situation.
+        */
+       if (suspend_ops) {
+               if (mem_sleep_default == PM_SUSPEND_TO_IDLE)
+                       mem_sleep_current = PM_SUSPEND_TO_IDLE;
+               else if ((mem_sleep_default == PM_SUSPEND_STANDBY) &&
+                               valid_state(PM_SUSPEND_STANDBY))
+                       mem_sleep_current = PM_SUSPEND_STANDBY;
+               else if ((mem_sleep_default >= PM_SUSPEND_MEM) &&
+                               valid_state(PM_SUSPEND_MEM))
+                       mem_sleep_current = PM_SUSPEND_MEM;
+       }
+
        return 1;
 }
 __setup("mem_sleep_default=", mem_sleep_default_setup);
--

2.25.1

#2 lore raw
In reply to xiongxin
Quoted 6 lines · xiongxin

From: xiongxin <[email protected]>

On the arm64 platform, the psci driver is used by default to set the suspend_ops structure; but the psci_acpi_init() function is called before the command-line parameter "mem_sleep_default=" is specified;

You seem to mean that psci_acpi_init() runs before mem_sleep_default_setup() and so there is a confusion regarding the mem_sleep_default setting.

Clearly, suspend_ops cannot be set before mem_sleep_default_setup() runs, so I'd prefer to fix the ordering instead of hacking the latter to fix up the mess.

Quoted 38 lines

the user cannot set the desired suspend mode through the "mem_sleep_default=" parameter;

In mem_sleep_default_setup(), judge whether suspend_ops is set, if it has been assigned, rewrite the value of mem_sleep_current variable; in order to complete the user setting;

kernel/power/suspend.c +15 -1
index d8cae434f9eb..bef4b17de3f6 100644
@@ -192,6 +192,21 @@ static int __init mem_sleep_default_setup(char *str)
                        break;
                }
 
+       /*
+        * When the suspend_ops has been set, "mem_sleep_default=*" will
+        * be invalid, here to fix this situation.
+        */
+       if (suspend_ops) {
+               if (mem_sleep_default == PM_SUSPEND_TO_IDLE)
+                       mem_sleep_current = PM_SUSPEND_TO_IDLE;
+               else if ((mem_sleep_default == PM_SUSPEND_STANDBY) &&
+                               valid_state(PM_SUSPEND_STANDBY))
+                       mem_sleep_current = PM_SUSPEND_STANDBY;
+               else if ((mem_sleep_default >= PM_SUSPEND_MEM) &&
+                               valid_state(PM_SUSPEND_MEM))
+                       mem_sleep_current = PM_SUSPEND_MEM;
+       }
+
        return 1;
 }
 __setup("mem_sleep_default=", mem_sleep_default_setup);
--

2.25.1