summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2025-01-13 19:36:57 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2025-01-20 17:16:16 +0100
commit92ce5c07b7a1913246fd5492aee52db8a0c66f55 (patch)
treee898179489d72e6a752bdcb6ad492ae1fb544c65
parent425b753645767049f1a3eab02f39120c02156b72 (diff)
cpuidle: teo: Reorder candidate state index checks
Since constraint_idx may be 0, the candidate state index may change to 0 after assigning constraint_idx to it, so first check if it is greater than constraint_idx (and update it if so) and then check it against 0. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Christian Loehle <christian.loehle@arm.com> Tested-by: Aboorva Devarajan <aboorvad@linux.ibm.com> Tested-by: Christian Loehle <christian.loehle@arm.com> Link: https://patch.msgid.link/1907276.tdWV9SEqCh@rjwysocki.net
-rw-r--r--drivers/cpuidle/governors/teo.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/cpuidle/governors/teo.c b/drivers/cpuidle/governors/teo.c
index 68af712f7064..30e444c9c40b 100644
--- a/drivers/cpuidle/governors/teo.c
+++ b/drivers/cpuidle/governors/teo.c
@@ -428,6 +428,14 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
break;
}
}
+
+ /*
+ * If there is a latency constraint, it may be necessary to select an
+ * idle state shallower than the current candidate one.
+ */
+ if (idx > constraint_idx)
+ idx = constraint_idx;
+
if (!idx && prev_intercept_idx) {
/*
* We have to query the sleep length here otherwise we don't
@@ -439,13 +447,6 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
}
/*
- * If there is a latency constraint, it may be necessary to select an
- * idle state shallower than the current candidate one.
- */
- if (idx > constraint_idx)
- idx = constraint_idx;
-
- /*
* Skip the timers check if state 0 is the current candidate one,
* because an immediate non-timer wakeup is expected in that case.
*/