Skip to content

Commit

Permalink
cpuidle: Rearrange s2idle-specific idle state entry code
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rafael J. Wysocki committed Jun 25, 2020
1 parent 81e6737 commit 10e8b11
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
6 changes: 3 additions & 3 deletions drivers/cpuidle/cpuidle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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 */
Expand Down
15 changes: 11 additions & 4 deletions kernel/sched/idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 10e8b11

Please sign in to comment.