diff options
Diffstat (limited to 'drivers/cpufreq/powernv-cpufreq.c')
-rw-r--r-- | drivers/cpufreq/powernv-cpufreq.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c index 87796e0864e9..d3ffde806629 100644 --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c | |||
@@ -145,11 +145,30 @@ static struct powernv_pstate_info { | |||
145 | /* Use following macros for conversions between pstate_id and index */ | 145 | /* Use following macros for conversions between pstate_id and index */ |
146 | static inline int idx_to_pstate(unsigned int i) | 146 | static inline int idx_to_pstate(unsigned int i) |
147 | { | 147 | { |
148 | if (unlikely(i >= powernv_pstate_info.nr_pstates)) { | ||
149 | pr_warn_once("index %u is out of bound\n", i); | ||
150 | return powernv_freqs[powernv_pstate_info.nominal].driver_data; | ||
151 | } | ||
152 | |||
148 | return powernv_freqs[i].driver_data; | 153 | return powernv_freqs[i].driver_data; |
149 | } | 154 | } |
150 | 155 | ||
151 | static inline unsigned int pstate_to_idx(int pstate) | 156 | static inline unsigned int pstate_to_idx(int pstate) |
152 | { | 157 | { |
158 | int min = powernv_freqs[powernv_pstate_info.min].driver_data; | ||
159 | int max = powernv_freqs[powernv_pstate_info.max].driver_data; | ||
160 | |||
161 | if (min > 0) { | ||
162 | if (unlikely((pstate < max) || (pstate > min))) { | ||
163 | pr_warn_once("pstate %d is out of bound\n", pstate); | ||
164 | return powernv_pstate_info.nominal; | ||
165 | } | ||
166 | } else { | ||
167 | if (unlikely((pstate > max) || (pstate < min))) { | ||
168 | pr_warn_once("pstate %d is out of bound\n", pstate); | ||
169 | return powernv_pstate_info.nominal; | ||
170 | } | ||
171 | } | ||
153 | /* | 172 | /* |
154 | * abs() is deliberately used so that is works with | 173 | * abs() is deliberately used so that is works with |
155 | * both monotonically increasing and decreasing | 174 | * both monotonically increasing and decreasing |
@@ -593,7 +612,7 @@ void gpstate_timer_handler(unsigned long data) | |||
593 | } else { | 612 | } else { |
594 | gpstate_idx = calc_global_pstate(gpstates->elapsed_time, | 613 | gpstate_idx = calc_global_pstate(gpstates->elapsed_time, |
595 | gpstates->highest_lpstate_idx, | 614 | gpstates->highest_lpstate_idx, |
596 | freq_data.pstate_id); | 615 | gpstates->last_lpstate_idx); |
597 | } | 616 | } |
598 | 617 | ||
599 | /* | 618 | /* |