Skip to content

Commit 800fb34

Browse files
committed
cpuidle: poll_state: Disregard disable idle states
When computing the limit of time to spend in the loop in poll_idle(), use the target residency of the first enabled idle state deeper than state 0 instead of always using the target residency of state 1. This helps when state 1 is disabled for diagnostics, for instance. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent aa5eee3 commit 800fb34

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/cpuidle/poll_state.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,17 @@ static int __cpuidle poll_idle(struct cpuidle_device *dev,
2020

2121
local_irq_enable();
2222
if (!current_set_polling_and_test()) {
23-
u64 limit = (u64)drv->states[1].target_residency * NSEC_PER_USEC;
2423
unsigned int loop_count = 0;
24+
u64 limit = TICK_USEC;
25+
int i;
26+
27+
for (i = 1; i < drv->state_count; i++) {
28+
if (drv->states[i].disabled || dev->states_usage[i].disable)
29+
continue;
30+
31+
limit = (u64)drv->states[i].target_residency * NSEC_PER_USEC;
32+
break;
33+
}
2534

2635
while (!need_resched()) {
2736
cpu_relax();

0 commit comments

Comments
 (0)