• Gautham R. Shenoy's avatar
    powernv-cpufreq: Fix pstate_to_idx() to handle non-continguous pstates · 332f0a01
    Gautham R. Shenoy authored
    The code in powernv-cpufreq, makes the following two assumptions which
    are not guaranteed by the device-tree bindings:
    
        1) Pstate ids are continguous: This is used in pstate_to_idx() to
           obtain the reverse map from a pstate to it's corresponding
           entry into the cpufreq frequency table.
    
        2) Every Pstate should always lie between the max and the min
           pstates that are explicitly reported in the device tree: This
           is used to determine whether a pstate reported by the PMSR is
           out of bounds.
    
    Both these assumptions are unwarranted and can change on future
    platforms.
    
    In this patch, we maintain the reverse map from a pstate to it's index
    in the cpufreq frequency table and use this in pstate_to_idx(). This
    does away with the assumptions (1) mentioned above, and will work with
    non continguous pstate ids. If no entry exists for a particular
    pstate, then such a pstate is treated as being out of bounds. This
    gets rid of assumption (2).
    
    On all the existing platforms, where the pstates are 8-bit long
    values, the new implementation of pstate_to_idx() takes constant time.
    Signed-off-by: default avatarGautham R. Shenoy <ego@linux.vnet.ibm.com>
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    332f0a01
powernv-cpufreq.c 30.2 KB