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.
Unified · Split
| @@ -1951,7 +1951,8 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) · 1950 unmodified lines | |||
| 1951 | limits = &performance_limits; | 1951 | limits = &performance_limits; |
| 1952 | perf_limits = limits; | 1952 | perf_limits = limits; |
| 1953 | } | 1953 | } |
| 1954 | if (policy->max >= policy->cpuinfo.max_freq) { | 1954 | if (policy->max >= policy->cpuinfo.max_freq && |
| 1955 | !limits->no_turbo) { | ||
| 1955 | pr_debug("set performance\n"); | 1956 | pr_debug("set performance\n"); |
| 1956 | intel_pstate_set_performance_limits(perf_limits); | 1957 | intel_pstate_set_performance_limits(perf_limits); |
| 1957 | goto out; | 1958 | goto out; |
| @@ -1993,6 +1994,17 @@ static int intel_pstate_verify_policy(struct cpufreq_policy *policy) · 35 unmodified lines | |||
| 1993 | policy->policy != CPUFREQ_POLICY_PERFORMANCE) | 1994 | policy->policy != CPUFREQ_POLICY_PERFORMANCE) |
| 1994 | return -EINVAL; | 1995 | return -EINVAL; |
| 1995 | 1996 | ||
| 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 | |||
| 1996 | return 0; | 2008 | return 0; |
| 1997 | } | 2009 | } |
| 1998 | 2010 | ||