cpuidle / menu: Return (-1) if there are no suitable states
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 30 Apr 2014 22:14:04 +0000 (00:14 +0200)
committerDanny Wood <danwood76@gmail.com>
Tue, 29 Jan 2019 13:09:07 +0000 (13:09 +0000)
commit 3836785a1bdcd6706c68ad46bf53adc0b057b310 upstream.

If there is a PM QoS latency limit and all of the sufficiently shallow
C-states are disabled, the cpuidle menu governor returns 0 which on
some systems is CPUIDLE_DRIVER_STATE_START and shouldn't be returned
if that C-state has been disabled.

Fix the issue by modifying the menu governor to return (-1) in such
situations.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[shilpab: Backport to 3.10.y
 - adjust context
 - add a check if 'next_state' is less than 0 in 'cpuidle_idle_call()',
   this ensures that we exit 'cpuidle_idle_call()' if governor->select()
   returns  negative value]
Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/cpuidle/cpuidle.c
drivers/cpuidle/governors/menu.c

index 2394b188121cff1478ea9a5f917a53881a4e6445..cffecb33a23b8cfe52bd177c7bfa3f8e6db47577 100644 (file)
@@ -140,6 +140,9 @@ int cpuidle_idle_call(void)
 
        /* ask the governor for the next state */
        next_state = cpuidle_curr_governor->select(drv, dev);
+       if (next_state < 0)
+               return -EBUSY;
+
        if (need_resched()) {
                dev->last_residency = 0;
                /* give the governor an opportunity to reflect on the outcome */
index e7156fb41b76029378a160a6d5467095afe99c75..afbe842fd1adabaa52f63f7a30519b7a2d576edb 100644 (file)
@@ -280,7 +280,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
                data->needs_update = 0;
        }
 
-       data->last_state_idx = 0;
+       data->last_state_idx = CPUIDLE_DRIVER_STATE_START - 1;
        data->exit_us = 0;
 
        /* Special case when user has set very strict latency requirement */