• Rafael J. Wysocki's avatar
    cpuidle: teo: Fix alternative idle state lookup · c2ec772b
    Rafael J. Wysocki authored
    There are three mistakes in the loop in teo_select() that is looking
    for an alternative candidate idle state.  First, it should walk all
    of the idle states shallower than the current candidate one,
    including all of the disabled ones, but it terminates after the first
    enabled idle state.  Second, it should not terminate its last step
    if idle state 0 is disabled (which is related to the first issue).
    Finally, it may return the current alternative candidate idle state
    prematurely if the time span criterion is not met by the idle state
    under consideration at the moment.
    
    To address the issues mentioned above, make the loop in question walk
    all of the idle states shallower than the current candidate idle state
    all the way down to idle state 0 and rearrange the checks in it.
    
    Fixes: 77577558 ("cpuidle: teo: Rework most recent idle duration values treatment")
    Reported-by: default avatarDoug Smythies <dsmythies@telus.net>
    Tested-by: default avatarDoug Smythies <dsmythies@telus.net>
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    c2ec772b
teo.c 17 KB