From 8000490ae5b3086ed4ff4d43f8560bdfd6ba9ced Mon Sep 17 00:00:00 2001 From: Raghavendra Kakarla Date: Sun, 26 Apr 2020 17:02:43 +0530 Subject: [PATCH] lpm-levels: Read next hrtimer event after tick_nohz_idle_stop_tick() idle_tick is a periodic timer which sends the interrupt to cpu for every jiffy. If next event is read before stopping the cpu idle_tick it gives the next tick expiry time as the next event. Current logic reading the cpu next event time before stopping the idle tick gives shallower sleep length recorded. This prevents cluster low power mode to get selected since next wakeup is seen either very near to current time or as already expired. Fix this to read next event after idle_tick has been stopped. Change-Id: I8016c7911dc48450668a8a6bc7a6d01d4423da32 Signed-off-by: Raghavendra Kakarla --- drivers/cpuidle/lpm-levels.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/cpuidle/lpm-levels.c b/drivers/cpuidle/lpm-levels.c index 3d26a5860c16..64a71856d0c9 100644 --- a/drivers/cpuidle/lpm-levels.c +++ b/drivers/cpuidle/lpm-levels.c @@ -524,9 +524,6 @@ static int cpu_power_select(struct cpuidle_device *dev, uint32_t min_residency, max_residency; struct power_params *pwr_params; - /* Read the timer from the CPU that is entering idle */ - cpu->next_hrtimer = tick_nohz_get_next_hrtimer(); - if (lpm_disallowed(sleep_us, dev->cpu)) goto done_select; @@ -1262,6 +1259,9 @@ static int lpm_cpuidle_enter(struct cpuidle_device *dev, uint64_t start_time = ktime_to_ns(start), end_time; int ret = -EBUSY; + /* Read the timer from the CPU that is entering idle */ + cpu->next_hrtimer = tick_nohz_get_next_hrtimer(); + cpu_prepare(cpu, idx, true); cluster_prepare(cpu->parent, cpumask, idx, true, start_time);