hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/thermal/intel/intel_powerclamp.c
....@@ -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 @@
261262 static unsigned int get_compensation(int ratio)
262263 {
263264 unsigned int comp = 0;
265
+
266
+ if (!poll_pkg_cstate_enable)
267
+ return 0;
264268
265269 /* we only use compensation if all adjacent ones are good */
266270 if (ratio == 1 &&
....@@ -534,7 +538,8 @@
534538 control_cpu = cpumask_first(cpu_online_mask);
535539
536540 clamping = true;
537
- schedule_delayed_work(&poll_pkg_cstate_work, 0);
541
+ if (poll_pkg_cstate_enable)
542
+ schedule_delayed_work(&poll_pkg_cstate_work, 0);
538543
539544 /* start one kthread worker per online cpu */
540545 for_each_online_cpu(cpu) {
....@@ -603,11 +608,15 @@
603608 static int powerclamp_get_cur_state(struct thermal_cooling_device *cdev,
604609 unsigned long *state)
605610 {
606
- if (true == clamping)
607
- *state = pkg_cstate_ratio_cur;
608
- else
611
+ if (clamping) {
612
+ if (poll_pkg_cstate_enable)
613
+ *state = pkg_cstate_ratio_cur;
614
+ else
615
+ *state = set_target_ratio;
616
+ } else {
609617 /* to save power, do not poll idle ratio while not clamping */
610618 *state = -1; /* indicates invalid state */
619
+ }
611620
612621 return 0;
613622 }
....@@ -732,6 +741,9 @@
732741 goto exit_unregister;
733742 }
734743
744
+ if (topology_max_packages() == 1 && topology_max_die_per_package() == 1)
745
+ poll_pkg_cstate_enable = true;
746
+
735747 cooling_dev = thermal_cooling_device_register("intel_powerclamp", NULL,
736748 &powerclamp_cooling_ops);
737749 if (IS_ERR(cooling_dev)) {