cpuidle: Rearrange s2idle-specific idle state entry code
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 25 Jun 2020 11:52:53 +0000 (13:52 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 25 Jun 2020 11:52:53 +0000 (13:52 +0200)
Implement call_cpuidle_s2idle() in analogy with call_cpuidle()
for the s2idle-specific idle state entry and invoke it from
cpuidle_idle_call() to make the s2idle-specific idle entry code
path look more similar to the "regular" idle entry one.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Chen Yu <yu.c.chen@intel.com>
drivers/cpuidle/cpuidle.c
kernel/sched/idle.c

index e092789187c63c6c2c165ac35c37ce5d82cf4848..87197319ab0694663033789ffdabe11f79ce23a5 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/mutex.h>
 #include <linux/sched.h>
 #include <linux/sched/clock.h>
-#include <linux/sched/idle.h>
 #include <linux/notifier.h>
 #include <linux/pm_qos.h>
 #include <linux/cpu.h>
@@ -187,9 +186,10 @@ int cpuidle_enter_s2idle(struct cpuidle_driver *drv, struct cpuidle_device *dev)
         * be frozen safely.
         */
        index = find_deepest_state(drv, dev, U64_MAX, 0, true);
-       if (index > 0 && !current_clr_polling_and_test())
+       if (index > 0) {
                enter_s2idle_proper(drv, dev, index);
-
+               local_irq_enable();
+       }
        return index;
 }
 #endif /* CONFIG_SUSPEND */
index 05deb81bb3e3d14d9157df6d6c66d924c2290816..1ae95b9150d3c06c6427431892670fa568261b79 100644 (file)
@@ -96,6 +96,15 @@ void __cpuidle default_idle_call(void)
        }
 }
 
+static int call_cpuidle_s2idle(struct cpuidle_driver *drv,
+                              struct cpuidle_device *dev)
+{
+       if (current_clr_polling_and_test())
+               return -EBUSY;
+
+       return cpuidle_enter_s2idle(drv, dev);
+}
+
 static int call_cpuidle(struct cpuidle_driver *drv, struct cpuidle_device *dev,
                      int next_state)
 {
@@ -171,11 +180,9 @@ static void cpuidle_idle_call(void)
                if (idle_should_enter_s2idle()) {
                        rcu_idle_enter();
 
-                       entered_state = cpuidle_enter_s2idle(drv, dev);
-                       if (entered_state > 0) {
-                               local_irq_enable();
+                       entered_state = call_cpuidle_s2idle(drv, dev);
+                       if (entered_state > 0)
                                goto exit_idle;
-                       }
 
                        rcu_idle_exit();