diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2017-03-21 17:19:07 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2017-03-21 17:19:07 -0400 |
commit | 64897b20eed29cee2b998fb5ba362e65523dba3c (patch) | |
tree | 31b8e9fdddad8ca4b50fbb285a5feed777c406a1 | |
parent | 7de32556dfc62b9e1203730cc26b71292da8a244 (diff) |
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: 001c76f05b01 (cpufreq: intel_pstate: Generic governors support)
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/cpufreq/intel_pstate.c | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 7b07803e7042..283491f742d3 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -2257,7 +2257,7 @@ static int intel_cpufreq_verify_policy(struct cpufreq_policy *policy) | |||
2257 | struct cpudata *cpu = all_cpu_data[policy->cpu]; | 2257 | struct cpudata *cpu = all_cpu_data[policy->cpu]; |
2258 | 2258 | ||
2259 | update_turbo_state(); | 2259 | update_turbo_state(); |
2260 | policy->cpuinfo.max_freq = global.turbo_disabled ? | 2260 | policy->cpuinfo.max_freq = global.no_turbo || global.turbo_disabled ? |
2261 | cpu->pstate.max_freq : cpu->pstate.turbo_freq; | 2261 | cpu->pstate.max_freq : cpu->pstate.turbo_freq; |
2262 | 2262 | ||
2263 | cpufreq_verify_within_cpu_limits(policy); | 2263 | cpufreq_verify_within_cpu_limits(policy); |
@@ -2265,26 +2265,6 @@ static int intel_cpufreq_verify_policy(struct cpufreq_policy *policy) | |||
2265 | return 0; | 2265 | return 0; |
2266 | } | 2266 | } |
2267 | 2267 | ||
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 | |||
2288 | static int intel_cpufreq_target(struct cpufreq_policy *policy, | 2268 | static int intel_cpufreq_target(struct cpufreq_policy *policy, |
2289 | unsigned int target_freq, | 2269 | unsigned int target_freq, |
2290 | unsigned int relation) | 2270 | unsigned int relation) |
@@ -2293,8 +2273,10 @@ static int intel_cpufreq_target(struct cpufreq_policy *policy, | |||
2293 | struct cpufreq_freqs freqs; | 2273 | struct cpufreq_freqs freqs; |
2294 | int target_pstate; | 2274 | int target_pstate; |
2295 | 2275 | ||
2276 | update_turbo_state(); | ||
2277 | |||
2296 | freqs.old = policy->cur; | 2278 | freqs.old = policy->cur; |
2297 | freqs.new = intel_cpufreq_turbo_update(cpu, policy, target_freq); | 2279 | freqs.new = target_freq; |
2298 | 2280 | ||
2299 | cpufreq_freq_transition_begin(policy, &freqs); | 2281 | cpufreq_freq_transition_begin(policy, &freqs); |
2300 | switch (relation) { | 2282 | switch (relation) { |
@@ -2326,7 +2308,8 @@ static unsigned int intel_cpufreq_fast_switch(struct cpufreq_policy *policy, | |||
2326 | struct cpudata *cpu = all_cpu_data[policy->cpu]; | 2308 | struct cpudata *cpu = all_cpu_data[policy->cpu]; |
2327 | int target_pstate; | 2309 | int target_pstate; |
2328 | 2310 | ||
2329 | target_freq = intel_cpufreq_turbo_update(cpu, policy, target_freq); | 2311 | update_turbo_state(); |
2312 | |||
2330 | target_pstate = DIV_ROUND_UP(target_freq, cpu->pstate.scaling); | 2313 | target_pstate = DIV_ROUND_UP(target_freq, cpu->pstate.scaling); |
2331 | target_pstate = intel_pstate_prepare_request(cpu, target_pstate); | 2314 | target_pstate = intel_pstate_prepare_request(cpu, target_pstate); |
2332 | intel_pstate_update_pstate(cpu, target_pstate); | 2315 | intel_pstate_update_pstate(cpu, target_pstate); |