Skip to content

Commit 30a3915

Browse files
spandruvadarafaeljw
authored andcommitted
cpufreq: intel_pstate: fix inconsistency in setting policy limits
When user sets performance policy using cpufreq interface, it is possible that because of policy->max limits, the actual performance is still limited. But the current implementation will silently switch the policy to powersave and start using powersave limits. If user modifies any limits using intel_pstate sysfs, this is actually changing powersave limits. The current implementation tracks limits under powersave and performance policy using two different variables. When policy->max is less than policy->cpuinfo.max_freq, only powersave limit variable is used. This fix causes the performance limits variable to be used always when the policy is performance. Signed-off-by: Srinivas Pandruvada <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent febce40 commit 30a3915

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

drivers/cpufreq/intel_pstate.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,22 +1141,39 @@ static void intel_pstate_clear_update_util_hook(unsigned int cpu)
11411141
synchronize_sched();
11421142
}
11431143

1144+
static void intel_pstate_set_performance_limits(struct perf_limits *limits)
1145+
{
1146+
limits->no_turbo = 0;
1147+
limits->turbo_disabled = 0;
1148+
limits->max_perf_pct = 100;
1149+
limits->max_perf = int_tofp(1);
1150+
limits->min_perf_pct = 100;
1151+
limits->min_perf = int_tofp(1);
1152+
limits->max_policy_pct = 100;
1153+
limits->max_sysfs_pct = 100;
1154+
limits->min_policy_pct = 0;
1155+
limits->min_sysfs_pct = 0;
1156+
}
1157+
11441158
static int intel_pstate_set_policy(struct cpufreq_policy *policy)
11451159
{
11461160
if (!policy->cpuinfo.max_freq)
11471161
return -ENODEV;
11481162

11491163
intel_pstate_clear_update_util_hook(policy->cpu);
11501164

1151-
if (policy->policy == CPUFREQ_POLICY_PERFORMANCE &&
1152-
policy->max >= policy->cpuinfo.max_freq) {
1153-
pr_debug("intel_pstate: set performance\n");
1165+
if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) {
11541166
limits = &performance_limits;
1155-
goto out;
1167+
if (policy->max >= policy->cpuinfo.max_freq) {
1168+
pr_debug("intel_pstate: set performance\n");
1169+
intel_pstate_set_performance_limits(limits);
1170+
goto out;
1171+
}
1172+
} else {
1173+
pr_debug("intel_pstate: set powersave\n");
1174+
limits = &powersave_limits;
11561175
}
11571176

1158-
pr_debug("intel_pstate: set powersave\n");
1159-
limits = &powersave_limits;
11601177
limits->min_policy_pct = (policy->min * 100) / policy->cpuinfo.max_freq;
11611178
limits->min_policy_pct = clamp_t(int, limits->min_policy_pct, 0 , 100);
11621179
limits->max_policy_pct = DIV_ROUND_UP(policy->max * 100,

0 commit comments

Comments
 (0)