History

cpufreq: intel_pstate: Fix sysfs limits enforcement for performance policy

A side effect of keeping intel_pstate sysfs limits in sync with cpufreq is that the now sysfs limits can't enforced under performance policy. For example, if the max_perf_pct is changed from 100 to 80, this will call intel_pstate_set_policy(), which will change the max_perf to 100 again for performance policy. Same issue happens, when no_turbo is set. This change calculates max and min frequency using sysfs performance limits in intel_pstate_verify_policy() and adjusts policy limits by calling cpufreq_verify_within_limits(). Also, it causes the setting of performance limits to be skipped if no_turbo is set.

Srinivas Pandruvada committed 9 years ago

Commit 1443ebb1 parent e11b6291 file · +13 −1Browse files

Unified · Split

drivers/cpufreq/intel_pstate.c+13−1
@@ -1951,7 +1951,8 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) · 1950 unmodified lines
19511951 limits = &performance_limits;
19521952 perf_limits = limits;
19531953 }
1954− if (policy->max >= policy->cpuinfo.max_freq) {
1954+ if (policy->max >= policy->cpuinfo.max_freq &&
1955+ !limits->no_turbo) {
19551956 pr_debug("set performance\n");
19561957 intel_pstate_set_performance_limits(perf_limits);
19571958 goto out;
@@ -1993,6 +1994,17 @@ static int intel_pstate_verify_policy(struct cpufreq_policy *policy) · 35 unmodified lines
19931994 policy->policy != CPUFREQ_POLICY_PERFORMANCE)
19941995 return -EINVAL;
19951996
1997+ /* When per-CPU limits are used, sysfs limits are not used */
1998+ if (!per_cpu_limits) {
1999+ unsigned int max_freq, min_freq;
2000+
2001+ max_freq = policy->cpuinfo.max_freq *
2002+ limits->max_sysfs_pct / 100;
2003+ min_freq = policy->cpuinfo.max_freq *
2004+ limits->min_sysfs_pct / 100;
2005+ cpufreq_verify_within_limits(policy, min_freq, max_freq);
2006+ }
2007+
19962008 return 0;
19972009 }
19982010