msm: kgsl: Fix a dead loop issue while changing gpu frequency

There is a dead loop in kgsl_devfreq_target(), while governor request
to change GPU frequency. In governor 'userspace' mode, If the requested
frequency (set_freq) is more than the configured frequency and max_freq
is also set to more than the configured frequency, then there is a dead
loop while changing target frequency.

Dead loop occurs due to comparing signed integer with unsigned integer.
So, type casting unsigned integer to signed integer will terminate the
loop when loop variable is less than zero.

Change-Id: Ic82b7477d50d1abcd348b011f64246066887922c
Signed-off-by: Venkateswara Rao Tadikonda <vtadik@codeaurora.org>
This commit is contained in:
Venkateswara Rao Tadikonda 2017-06-27 13:05:10 +05:30
parent 20e0861617
commit aac10e39c7

View file

@ -550,7 +550,11 @@ int kgsl_devfreq_target(struct device *dev, unsigned long *freq, u32 flags)
/* If the governor recommends a new frequency, update it here */ /* If the governor recommends a new frequency, update it here */
if (*freq != cur_freq) { if (*freq != cur_freq) {
level = pwr->max_pwrlevel; level = pwr->max_pwrlevel;
for (i = pwr->min_pwrlevel; i >= pwr->max_pwrlevel; i--) /*
* To avoid infinite loop issue type cast max_pwrlevel to
* signed integer type
*/
for (i = pwr->min_pwrlevel; i >= (int)pwr->max_pwrlevel; i--)
if (*freq <= pwr->pwrlevels[i].gpu_freq) { if (*freq <= pwr->pwrlevels[i].gpu_freq) {
if (pwr->thermal_cycle == CYCLE_ACTIVE) if (pwr->thermal_cycle == CYCLE_ACTIVE)
level = _thermal_adjust(pwr, i); level = _thermal_adjust(pwr, i);