Skip to content

Commit 92ce5c0

Browse files
committed
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 <[email protected]> Reviewed-by: Christian Loehle <[email protected]> Tested-by: Aboorva Devarajan <[email protected]> Tested-by: Christian Loehle <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 425b753 commit 92ce5c0

File tree

1 file changed

+8
-7
lines changed
  • drivers/cpuidle/governors

1 file changed

+8
-7
lines changed

drivers/cpuidle/governors/teo.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,14 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
428428
break;
429429
}
430430
}
431+
432+
/*
433+
* If there is a latency constraint, it may be necessary to select an
434+
* idle state shallower than the current candidate one.
435+
*/
436+
if (idx > constraint_idx)
437+
idx = constraint_idx;
438+
431439
if (!idx && prev_intercept_idx) {
432440
/*
433441
* We have to query the sleep length here otherwise we don't
@@ -438,13 +446,6 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
438446
goto out_tick;
439447
}
440448

441-
/*
442-
* If there is a latency constraint, it may be necessary to select an
443-
* idle state shallower than the current candidate one.
444-
*/
445-
if (idx > constraint_idx)
446-
idx = constraint_idx;
447-
448449
/*
449450
* Skip the timers check if state 0 is the current candidate one,
450451
* because an immediate non-timer wakeup is expected in that case.

0 commit comments

Comments
 (0)