Skip to content

Commit 64897b2

Browse files
committed
cpufreq: intel_pstate: Fix policy data management in passive mode
The policy->cpuinfo.max_freq and policy->max updates in intel_cpufreq_turbo_update() are excessive as they are done for no good reason and may lead to problems in principle, so they should be dropped. However, after dropping them intel_cpufreq_turbo_update() becomes almost entirely pointless, because the check made by it is made again down the road in intel_pstate_prepare_request(). The only thing in it that still needs to be done is the call to update_turbo_state(), so drop intel_cpufreq_turbo_update() altogether and make its callers invoke update_turbo_state() directly instead of it. In addition to that, fix intel_cpufreq_verify_policy() so that it checks global.no_turbo in addition to global.turbo_disabled when updating policy->cpuinfo.max_freq to make it consistent with intel_pstate_verify_policy(). Fixes: 001c76f (cpufreq: intel_pstate: Generic governors support) Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 7de3255 commit 64897b2

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

drivers/cpufreq/intel_pstate.c

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,34 +2257,14 @@ static int intel_cpufreq_verify_policy(struct cpufreq_policy *policy)
22572257
struct cpudata *cpu = all_cpu_data[policy->cpu];
22582258

22592259
update_turbo_state();
2260-
policy->cpuinfo.max_freq = global.turbo_disabled ?
2260+
policy->cpuinfo.max_freq = global.no_turbo || global.turbo_disabled ?
22612261
cpu->pstate.max_freq : cpu->pstate.turbo_freq;
22622262

22632263
cpufreq_verify_within_cpu_limits(policy);
22642264

22652265
return 0;
22662266
}
22672267

2268-
static unsigned int intel_cpufreq_turbo_update(struct cpudata *cpu,
2269-
struct cpufreq_policy *policy,
2270-
unsigned int target_freq)
2271-
{
2272-
unsigned int max_freq;
2273-
2274-
update_turbo_state();
2275-
2276-
max_freq = global.no_turbo || global.turbo_disabled ?
2277-
cpu->pstate.max_freq : cpu->pstate.turbo_freq;
2278-
policy->cpuinfo.max_freq = max_freq;
2279-
if (policy->max > max_freq)
2280-
policy->max = max_freq;
2281-
2282-
if (target_freq > max_freq)
2283-
target_freq = max_freq;
2284-
2285-
return target_freq;
2286-
}
2287-
22882268
static int intel_cpufreq_target(struct cpufreq_policy *policy,
22892269
unsigned int target_freq,
22902270
unsigned int relation)
@@ -2293,8 +2273,10 @@ static int intel_cpufreq_target(struct cpufreq_policy *policy,
22932273
struct cpufreq_freqs freqs;
22942274
int target_pstate;
22952275

2276+
update_turbo_state();
2277+
22962278
freqs.old = policy->cur;
2297-
freqs.new = intel_cpufreq_turbo_update(cpu, policy, target_freq);
2279+
freqs.new = target_freq;
22982280

22992281
cpufreq_freq_transition_begin(policy, &freqs);
23002282
switch (relation) {
@@ -2326,7 +2308,8 @@ static unsigned int intel_cpufreq_fast_switch(struct cpufreq_policy *policy,
23262308
struct cpudata *cpu = all_cpu_data[policy->cpu];
23272309
int target_pstate;
23282310

2329-
target_freq = intel_cpufreq_turbo_update(cpu, policy, target_freq);
2311+
update_turbo_state();
2312+
23302313
target_pstate = DIV_ROUND_UP(target_freq, cpu->pstate.scaling);
23312314
target_pstate = intel_pstate_prepare_request(cpu, target_pstate);
23322315
intel_pstate_update_pstate(cpu, target_pstate);

0 commit comments

Comments
 (0)