Skip to content

Commit 8e47363

Browse files
spandruvadarafaeljw
authored andcommitted
thermal: intel: powerclamp: Fix cur_state for multi package system
The powerclamp cooling device cur_state shows actual idle observed by package C-state idle counters. But the implementation is not sufficient for multi package or multi die system. The cur_state value is incorrect. On these systems, these counters must be read from each package/die and somehow aggregate them. But there is no good method for aggregation. It was not a problem when explicit CPU model addition was required to enable intel powerclamp. In this way certain CPU models could have been avoided. But with the removal of CPU model check with the availability of Package C-state counters, the driver is loaded on most of the recent systems. For multi package/die systems, just show the actual target idle state, the system is trying to achieve. In powerclamp this is the user set state minus one. Also there is no use of starting a worker thread for polling package C-state counters and applying any compensation for multiple package or multiple die systems. Fixes: b721ca0 ("thermal/powerclamp: remove cpu whitelist") Signed-off-by: Srinivas Pandruvada <[email protected]> Cc: 4.14+ <[email protected]> # 4.14+ Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 2153a87 commit 8e47363

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

drivers/thermal/intel/intel_powerclamp.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757

5858
static unsigned int target_mwait;
5959
static struct dentry *debug_dir;
60+
static bool poll_pkg_cstate_enable;
6061

6162
/* user selected target */
6263
static unsigned int set_target_ratio;
@@ -261,6 +262,9 @@ static unsigned int get_compensation(int ratio)
261262
{
262263
unsigned int comp = 0;
263264

265+
if (!poll_pkg_cstate_enable)
266+
return 0;
267+
264268
/* we only use compensation if all adjacent ones are good */
265269
if (ratio == 1 &&
266270
cal_data[ratio].confidence >= CONFIDENCE_OK &&
@@ -519,7 +523,8 @@ static int start_power_clamp(void)
519523
control_cpu = cpumask_first(cpu_online_mask);
520524

521525
clamping = true;
522-
schedule_delayed_work(&poll_pkg_cstate_work, 0);
526+
if (poll_pkg_cstate_enable)
527+
schedule_delayed_work(&poll_pkg_cstate_work, 0);
523528

524529
/* start one kthread worker per online cpu */
525530
for_each_online_cpu(cpu) {
@@ -585,11 +590,15 @@ static int powerclamp_get_max_state(struct thermal_cooling_device *cdev,
585590
static int powerclamp_get_cur_state(struct thermal_cooling_device *cdev,
586591
unsigned long *state)
587592
{
588-
if (true == clamping)
589-
*state = pkg_cstate_ratio_cur;
590-
else
593+
if (clamping) {
594+
if (poll_pkg_cstate_enable)
595+
*state = pkg_cstate_ratio_cur;
596+
else
597+
*state = set_target_ratio;
598+
} else {
591599
/* to save power, do not poll idle ratio while not clamping */
592600
*state = -1; /* indicates invalid state */
601+
}
593602

594603
return 0;
595604
}
@@ -712,6 +721,9 @@ static int __init powerclamp_init(void)
712721
goto exit_unregister;
713722
}
714723

724+
if (topology_max_packages() == 1 && topology_max_die_per_package() == 1)
725+
poll_pkg_cstate_enable = true;
726+
715727
cooling_dev = thermal_cooling_device_register("intel_powerclamp", NULL,
716728
&powerclamp_cooling_ops);
717729
if (IS_ERR(cooling_dev)) {

0 commit comments

Comments
 (0)