Skip to content

Commit 27f8508

Browse files
mrkajetanprafaeljw
authored andcommitted
cpuidle: teo: Optionally skip polling states in teo_find_shallower_state()
Add a no_poll flag to teo_find_shallower_state() that will let the function optionally not consider polling states. This allows the caller to guard against the function inadvertently resulting in TEO putting the CPU in a polling state when that behaviour is undesirable. Signed-off-by: Kajetan Puchalski <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent b7bfaa7 commit 27f8508

File tree

1 file changed

+5
-3
lines changed
  • drivers/cpuidle/governors

1 file changed

+5
-3
lines changed

drivers/cpuidle/governors/teo.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,17 @@ static s64 teo_middle_of_bin(int idx, struct cpuidle_driver *drv)
258258
* @dev: Target CPU.
259259
* @state_idx: Index of the capping idle state.
260260
* @duration_ns: Idle duration value to match.
261+
* @no_poll: Don't consider polling states.
261262
*/
262263
static int teo_find_shallower_state(struct cpuidle_driver *drv,
263264
struct cpuidle_device *dev, int state_idx,
264-
s64 duration_ns)
265+
s64 duration_ns, bool no_poll)
265266
{
266267
int i;
267268

268269
for (i = state_idx - 1; i >= 0; i--) {
269-
if (dev->states_usage[i].disable)
270+
if (dev->states_usage[i].disable ||
271+
(no_poll && drv->states[i].flags & CPUIDLE_FLAG_POLLING))
270272
continue;
271273

272274
state_idx = i;
@@ -469,7 +471,7 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
469471
*/
470472
if (idx > idx0 &&
471473
drv->states[idx].target_residency_ns > delta_tick)
472-
idx = teo_find_shallower_state(drv, dev, idx, delta_tick);
474+
idx = teo_find_shallower_state(drv, dev, idx, delta_tick, false);
473475
}
474476

475477
return idx;

0 commit comments

Comments
 (0)