@@ -388,7 +388,7 @@ static int clamp_thread(void *arg)
388
388
int sleeptime ;
389
389
unsigned long target_jiffies ;
390
390
unsigned int guard ;
391
- unsigned int compensation = 0 ;
391
+ unsigned int compensated_ratio ;
392
392
int interval ; /* jiffies to sleep for each attempt */
393
393
unsigned int duration_jiffies = msecs_to_jiffies (duration );
394
394
unsigned int window_size_now ;
@@ -409,8 +409,11 @@ static int clamp_thread(void *arg)
409
409
* c-states, thus we need to compensate the injected idle ratio
410
410
* to achieve the actual target reported by the HW.
411
411
*/
412
- compensation = get_compensation (target_ratio );
413
- interval = duration_jiffies * 100 /(target_ratio + compensation );
412
+ compensated_ratio = target_ratio +
413
+ get_compensation (target_ratio );
414
+ if (compensated_ratio <= 0 )
415
+ compensated_ratio = 1 ;
416
+ interval = duration_jiffies * 100 / compensated_ratio ;
414
417
415
418
/* align idle time */
416
419
target_jiffies = roundup (jiffies , interval );
@@ -647,8 +650,8 @@ static int powerclamp_set_cur_state(struct thermal_cooling_device *cdev,
647
650
goto exit_set ;
648
651
} else if (set_target_ratio > 0 && new_target_ratio == 0 ) {
649
652
pr_info ("Stop forced idle injection\n" );
650
- set_target_ratio = 0 ;
651
653
end_power_clamp ();
654
+ set_target_ratio = 0 ;
652
655
} else /* adjust currently running */ {
653
656
set_target_ratio = new_target_ratio ;
654
657
/* make new set_target_ratio visible to other cpus */
0 commit comments