From 226509c1ee0e257d2646fd4aec9a594f4c31dab0 Mon Sep 17 00:00:00 2001 From: Archana Sathyakumar Date: Fri, 24 Jun 2016 16:19:37 -0600 Subject: [PATCH] lpm-levels: Fix cpu idle trace and stats event In the event that the cpu needs to be rescheduled for another task before it enters psci sleep, the stats and trace exit events are considered without the enter events. Fix this issue by moving enter events before the cpu gets scheduled. Change-Id: I8e477c434d218960b48aab4e61cacf99476b607f Signed-off-by: Archana Sathyakumar --- drivers/cpuidle/lpm-levels.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/cpuidle/lpm-levels.c b/drivers/cpuidle/lpm-levels.c index 956f435c08be..3f8a3927ff92 100644 --- a/drivers/cpuidle/lpm-levels.c +++ b/drivers/cpuidle/lpm-levels.c @@ -1026,12 +1026,13 @@ static int lpm_cpuidle_enter(struct cpuidle_device *dev, cpu_prepare(cluster, idx, true); cluster_prepare(cluster, cpumask, idx, true, ktime_to_ns(ktime_get())); + trace_cpu_idle_enter(idx); + lpm_stats_cpu_enter(idx, start_time); + if (need_resched() || (idx < 0)) goto exit; BUG_ON(!use_psci); - trace_cpu_idle_enter(idx); - lpm_stats_cpu_enter(idx, start_time); success = psci_enter_sleep(cluster, idx, true); exit: