|
57 | 57 |
|
58 | 58 | static unsigned int target_mwait;
|
59 | 59 | static struct dentry *debug_dir;
|
| 60 | +static bool poll_pkg_cstate_enable; |
60 | 61 |
|
61 | 62 | /* user selected target */
|
62 | 63 | static unsigned int set_target_ratio;
|
@@ -261,6 +262,9 @@ static unsigned int get_compensation(int ratio)
|
261 | 262 | {
|
262 | 263 | unsigned int comp = 0;
|
263 | 264 |
|
| 265 | + if (!poll_pkg_cstate_enable) |
| 266 | + return 0; |
| 267 | + |
264 | 268 | /* we only use compensation if all adjacent ones are good */
|
265 | 269 | if (ratio == 1 &&
|
266 | 270 | cal_data[ratio].confidence >= CONFIDENCE_OK &&
|
@@ -519,7 +523,8 @@ static int start_power_clamp(void)
|
519 | 523 | control_cpu = cpumask_first(cpu_online_mask);
|
520 | 524 |
|
521 | 525 | 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); |
523 | 528 |
|
524 | 529 | /* start one kthread worker per online cpu */
|
525 | 530 | for_each_online_cpu(cpu) {
|
@@ -585,11 +590,15 @@ static int powerclamp_get_max_state(struct thermal_cooling_device *cdev,
|
585 | 590 | static int powerclamp_get_cur_state(struct thermal_cooling_device *cdev,
|
586 | 591 | unsigned long *state)
|
587 | 592 | {
|
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 { |
591 | 599 | /* to save power, do not poll idle ratio while not clamping */
|
592 | 600 | *state = -1; /* indicates invalid state */
|
| 601 | + } |
593 | 602 |
|
594 | 603 | return 0;
|
595 | 604 | }
|
@@ -712,6 +721,9 @@ static int __init powerclamp_init(void)
|
712 | 721 | goto exit_unregister;
|
713 | 722 | }
|
714 | 723 |
|
| 724 | + if (topology_max_packages() == 1 && topology_max_die_per_package() == 1) |
| 725 | + poll_pkg_cstate_enable = true; |
| 726 | + |
715 | 727 | cooling_dev = thermal_cooling_device_register("intel_powerclamp", NULL,
|
716 | 728 | &powerclamp_cooling_ops);
|
717 | 729 | if (IS_ERR(cooling_dev)) {
|
|
0 commit comments