summaryrefslogtreecommitdiffstats
path: root/drivers/thermal/intel_powerclamp.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2016-09-13 10:31:40 +0200
committerLinus Walleij <linus.walleij@linaro.org>2016-09-13 10:31:40 +0200
commiteb8994172a45029f3f589fd6b2bd5d54e5b6e036 (patch)
treee99afa7659fdd6577616e110662386575b721b2c /drivers/thermal/intel_powerclamp.c
parentgpio: pca953x: initialize ret to zero to avoid returning garbage (diff)
parentLinux 4.8-rc2 (diff)
downloadlinux-eb8994172a45029f3f589fd6b2bd5d54e5b6e036.tar.xz
linux-eb8994172a45029f3f589fd6b2bd5d54e5b6e036.zip
Merge tag 'v4.8-rc2' into devel
Linux 4.8-rc2
Diffstat (limited to 'drivers/thermal/intel_powerclamp.c')
-rw-r--r--drivers/thermal/intel_powerclamp.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/thermal/intel_powerclamp.c b/drivers/thermal/intel_powerclamp.c
index 015ce2eb6eb7..0e4dc0afcfd2 100644
--- a/drivers/thermal/intel_powerclamp.c
+++ b/drivers/thermal/intel_powerclamp.c
@@ -388,7 +388,7 @@ static int clamp_thread(void *arg)
int sleeptime;
unsigned long target_jiffies;
unsigned int guard;
- unsigned int compensation = 0;
+ unsigned int compensated_ratio;
int interval; /* jiffies to sleep for each attempt */
unsigned int duration_jiffies = msecs_to_jiffies(duration);
unsigned int window_size_now;
@@ -409,8 +409,11 @@ static int clamp_thread(void *arg)
* c-states, thus we need to compensate the injected idle ratio
* to achieve the actual target reported by the HW.
*/
- compensation = get_compensation(target_ratio);
- interval = duration_jiffies*100/(target_ratio+compensation);
+ compensated_ratio = target_ratio +
+ get_compensation(target_ratio);
+ if (compensated_ratio <= 0)
+ compensated_ratio = 1;
+ interval = duration_jiffies * 100 / compensated_ratio;
/* align idle time */
target_jiffies = roundup(jiffies, interval);
@@ -647,8 +650,8 @@ static int powerclamp_set_cur_state(struct thermal_cooling_device *cdev,
goto exit_set;
} else if (set_target_ratio > 0 && new_target_ratio == 0) {
pr_info("Stop forced idle injection\n");
- set_target_ratio = 0;
end_power_clamp();
+ set_target_ratio = 0;
} else /* adjust currently running */ {
set_target_ratio = new_target_ratio;
/* make new set_target_ratio visible to other cpus */