summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-07-21 02:07:54 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-07-24 23:53:44 +0200
commit8e6bcd9f7eac47104ce6c5d82c554c9b244b38e1 (patch)
tree74a789ae4c8825bb513a1a8e75c6613dbace2208
parentPM / timekeeping: Print debug messages when requested (diff)
downloadlinux-8e6bcd9f7eac47104ce6c5d82c554c9b244b38e1.tar.xz
linux-8e6bcd9f7eac47104ce6c5d82c554c9b244b38e1.zip
PM / s2idle: Rearrange the main suspend-to-idle loop
As a preparation for subsequent changes, rearrange the core suspend-to-idle code by moving the initial invocation of dpm_suspend_noirq() into s2idle_loop(). This also causes debug messages from that code to appear in a less confusing order. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--kernel/power/power.h4
-rw-r--r--kernel/power/suspend.c26
2 files changed, 17 insertions, 13 deletions
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 7fdc40d31b7d..6e3ac6a73d65 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -245,7 +245,11 @@ enum {
#define TEST_FIRST TEST_NONE
#define TEST_MAX (__TEST_AFTER_LAST - 1)
+#ifdef CONFIG_PM_DEBUG
extern int pm_test_level;
+#else
+#define pm_test_level (TEST_NONE)
+#endif
#ifdef CONFIG_SUSPEND_FREEZER
static inline int suspend_freeze_processes(void)
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 18cdb1596d27..0c61713b6e5c 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -108,7 +108,13 @@ static void s2idle_loop(void)
{
pm_pr_dbg("suspend-to-idle\n");
- do {
+ while (!dpm_suspend_noirq(PMSG_SUSPEND)) {
+ /*
+ * Suspend-to-idle equals
+ * frozen processes + suspended devices + idle processors.
+ * Thus freeze_enter() should be called right after
+ * all devices have been suspended.
+ */
freeze_enter();
if (freeze_ops && freeze_ops->wake)
@@ -122,7 +128,7 @@ static void s2idle_loop(void)
break;
pm_wakeup_clear(false);
- } while (!dpm_suspend_noirq(PMSG_SUSPEND));
+ }
pm_pr_dbg("resume from suspend-to-idle\n");
}
@@ -379,6 +385,11 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
if (error)
goto Devices_early_resume;
+ if (state == PM_SUSPEND_FREEZE && pm_test_level != TEST_PLATFORM) {
+ s2idle_loop();
+ goto Platform_early_resume;
+ }
+
error = dpm_suspend_noirq(PMSG_SUSPEND);
if (error) {
pr_err("PM: noirq suspend of devices failed\n");
@@ -391,17 +402,6 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
if (suspend_test(TEST_PLATFORM))
goto Platform_wake;
- /*
- * PM_SUSPEND_FREEZE equals
- * frozen processes + suspended devices + idle processors.
- * Thus we should invoke freeze_enter() soon after
- * all the devices are suspended.
- */
- if (state == PM_SUSPEND_FREEZE) {
- s2idle_loop();
- goto Platform_early_resume;
- }
-
error = disable_nonboot_cpus();
if (error || suspend_test(TEST_CPUS))
goto Enable_cpus;