Skip to content

Commit

Permalink
cpuidle: poll_state: Disregard disable idle states
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rafael J. Wysocki committed Dec 11, 2018
1 parent aa5eee3 commit 800fb34
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion drivers/cpuidle/poll_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,17 @@ static int __cpuidle poll_idle(struct cpuidle_device *dev,

local_irq_enable();
if (!current_set_polling_and_test()) {
u64 limit = (u64)drv->states[1].target_residency * NSEC_PER_USEC;
unsigned int loop_count = 0;
u64 limit = TICK_USEC;
int i;

for (i = 1; i < drv->state_count; i++) {
if (drv->states[i].disabled || dev->states_usage[i].disable)
continue;

limit = (u64)drv->states[i].target_residency * NSEC_PER_USEC;
break;
}

while (!need_resched()) {
cpu_relax();
Expand Down

0 comments on commit 800fb34

Please sign in to comment.