cpuidle: poll_state: Disregard disable idle states
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 3 Dec 2018 12:32:53 +0000 (13:32 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 11 Dec 2018 11:07:07 +0000 (12:07 +0100)
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>
drivers/cpuidle/poll_state.c

index 85792d371add6558ffd429da2b0b6638c64ac921..b17d153e724fd3c693930ad67583e4804a8b580d 100644 (file)
@@ -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();