|
@@ -2021,19 +2021,25 @@ static void intel_pstate_clear_update_util_hook(unsigned int cpu)
|
|
|
synchronize_sched();
|
|
|
}
|
|
|
|
|
|
+static int intel_pstate_get_max_freq(struct cpudata *cpu)
|
|
|
+{
|
|
|
+ return global.turbo_disabled || global.no_turbo ?
|
|
|
+ cpu->pstate.max_freq : cpu->pstate.turbo_freq;
|
|
|
+}
|
|
|
+
|
|
|
static void intel_pstate_update_perf_limits(struct cpufreq_policy *policy,
|
|
|
struct cpudata *cpu)
|
|
|
{
|
|
|
struct perf_limits *limits = &cpu->perf_limits;
|
|
|
+ int max_freq = intel_pstate_get_max_freq(cpu);
|
|
|
int32_t max_policy_perf, min_policy_perf;
|
|
|
|
|
|
- max_policy_perf = div_ext_fp(policy->max, policy->cpuinfo.max_freq);
|
|
|
+ max_policy_perf = div_ext_fp(policy->max, max_freq);
|
|
|
max_policy_perf = clamp_t(int32_t, max_policy_perf, 0, int_ext_tofp(1));
|
|
|
if (policy->max == policy->min) {
|
|
|
min_policy_perf = max_policy_perf;
|
|
|
} else {
|
|
|
- min_policy_perf = div_ext_fp(policy->min,
|
|
|
- policy->cpuinfo.max_freq);
|
|
|
+ min_policy_perf = div_ext_fp(policy->min, max_freq);
|
|
|
min_policy_perf = clamp_t(int32_t, min_policy_perf,
|
|
|
0, max_policy_perf);
|
|
|
}
|
|
@@ -2048,7 +2054,7 @@ static void intel_pstate_update_perf_limits(struct cpufreq_policy *policy,
|
|
|
/* Global limits are in percent of the maximum turbo P-state. */
|
|
|
global_max = percent_ext_fp(global.max_perf_pct);
|
|
|
global_min = percent_ext_fp(global.min_perf_pct);
|
|
|
- if (policy->cpuinfo.max_freq != cpu->pstate.turbo_freq) {
|
|
|
+ if (max_freq != cpu->pstate.turbo_freq) {
|
|
|
int32_t turbo_factor;
|
|
|
|
|
|
turbo_factor = div_ext_fp(cpu->pstate.turbo_pstate,
|
|
@@ -2088,13 +2094,6 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
|
|
|
cpu = all_cpu_data[policy->cpu];
|
|
|
cpu->policy = policy->policy;
|
|
|
|
|
|
- if (cpu->pstate.max_pstate_physical > cpu->pstate.max_pstate &&
|
|
|
- policy->max < policy->cpuinfo.max_freq &&
|
|
|
- policy->max > cpu->pstate.max_pstate * cpu->pstate.scaling) {
|
|
|
- pr_debug("policy->max > max non turbo frequency\n");
|
|
|
- policy->max = policy->cpuinfo.max_freq;
|
|
|
- }
|
|
|
-
|
|
|
mutex_lock(&intel_pstate_limits_lock);
|
|
|
|
|
|
intel_pstate_update_perf_limits(policy, cpu);
|
|
@@ -2118,21 +2117,31 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+static void intel_pstate_adjust_policy_max(struct cpufreq_policy *policy,
|
|
|
+ struct cpudata *cpu)
|
|
|
+{
|
|
|
+ if (cpu->pstate.max_pstate_physical > cpu->pstate.max_pstate &&
|
|
|
+ policy->max < policy->cpuinfo.max_freq &&
|
|
|
+ policy->max > cpu->pstate.max_freq) {
|
|
|
+ pr_debug("policy->max > max non turbo frequency\n");
|
|
|
+ policy->max = policy->cpuinfo.max_freq;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
static int intel_pstate_verify_policy(struct cpufreq_policy *policy)
|
|
|
{
|
|
|
struct cpudata *cpu = all_cpu_data[policy->cpu];
|
|
|
|
|
|
update_turbo_state();
|
|
|
- policy->cpuinfo.max_freq = global.turbo_disabled || global.no_turbo ?
|
|
|
- cpu->pstate.max_freq :
|
|
|
- cpu->pstate.turbo_freq;
|
|
|
-
|
|
|
- cpufreq_verify_within_cpu_limits(policy);
|
|
|
+ cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
|
|
|
+ intel_pstate_get_max_freq(cpu));
|
|
|
|
|
|
if (policy->policy != CPUFREQ_POLICY_POWERSAVE &&
|
|
|
policy->policy != CPUFREQ_POLICY_PERFORMANCE)
|
|
|
return -EINVAL;
|
|
|
|
|
|
+ intel_pstate_adjust_policy_max(policy, cpu);
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -2227,10 +2236,10 @@ static int intel_cpufreq_verify_policy(struct cpufreq_policy *policy)
|
|
|
struct cpudata *cpu = all_cpu_data[policy->cpu];
|
|
|
|
|
|
update_turbo_state();
|
|
|
- policy->cpuinfo.max_freq = global.no_turbo || global.turbo_disabled ?
|
|
|
- cpu->pstate.max_freq : cpu->pstate.turbo_freq;
|
|
|
+ cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
|
|
|
+ intel_pstate_get_max_freq(cpu));
|
|
|
|
|
|
- cpufreq_verify_within_cpu_limits(policy);
|
|
|
+ intel_pstate_adjust_policy_max(policy, cpu);
|
|
|
|
|
|
intel_pstate_update_perf_limits(policy, cpu);
|
|
|
|