aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/cpufreq/intel_pstate.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index c6e10d02b795..4a437ffc5186 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -117,6 +117,8 @@ struct perf_limits {
117 int min_perf_pct; 117 int min_perf_pct;
118 int32_t max_perf; 118 int32_t max_perf;
119 int32_t min_perf; 119 int32_t min_perf;
120 int max_policy_pct;
121 int max_sysfs_pct;
120}; 122};
121 123
122static struct perf_limits limits = { 124static struct perf_limits limits = {
@@ -125,6 +127,8 @@ static struct perf_limits limits = {
125 .max_perf = int_tofp(1), 127 .max_perf = int_tofp(1),
126 .min_perf_pct = 0, 128 .min_perf_pct = 0,
127 .min_perf = 0, 129 .min_perf = 0,
130 .max_policy_pct = 100,
131 .max_sysfs_pct = 100,
128}; 132};
129 133
130static inline void pid_reset(struct _pid *pid, int setpoint, int busy, 134static inline void pid_reset(struct _pid *pid, int setpoint, int busy,
@@ -295,7 +299,8 @@ static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b,
295 if (ret != 1) 299 if (ret != 1)
296 return -EINVAL; 300 return -EINVAL;
297 301
298 limits.max_perf_pct = clamp_t(int, input, 0 , 100); 302 limits.max_sysfs_pct = clamp_t(int, input, 0 , 100);
303 limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct);
299 limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100)); 304 limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100));
300 return count; 305 return count;
301} 306}
@@ -646,8 +651,9 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
646 limits.min_perf_pct = clamp_t(int, limits.min_perf_pct, 0 , 100); 651 limits.min_perf_pct = clamp_t(int, limits.min_perf_pct, 0 , 100);
647 limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100)); 652 limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100));
648 653
649 limits.max_perf_pct = policy->max * 100 / policy->cpuinfo.max_freq; 654 limits.max_policy_pct = policy->max * 100 / policy->cpuinfo.max_freq;
650 limits.max_perf_pct = clamp_t(int, limits.max_perf_pct, 0 , 100); 655 limits.max_policy_pct = clamp_t(int, limits.max_policy_pct, 0 , 100);
656 limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct);
651 limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100)); 657 limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100));
652 658
653 return 0; 659 return 0;