Skip to content

Commit b989bc0

Browse files
committed
cpufreq: intel_pstate: Simplify intel_pstate_update_perf_limits()
Because pstate.max_freq is always equal to the product of pstate.max_pstate and pstate.scaling and, analogously, pstate.turbo_freq is always equal to the product of pstate.turbo_pstate and pstate.scaling, the result of the max_policy_perf computation in intel_pstate_update_perf_limits() is always equal to the quotient of policy_max and pstate.scaling, regardless of whether or not turbo is disabled. Analogously, the result of min_policy_perf in intel_pstate_update_perf_limits() is always equal to the quotient of policy_min and pstate.scaling. Accordingly, intel_pstate_update_perf_limits() need not check whether or not turbo is enabled at all and in order to compute max_policy_perf and min_policy_perf it can always divide policy_max and policy_min, respectively, by pstate.scaling. Make it do so. While at it, move the definition and initialization of the turbo_max local variable to the code branch using it. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Tested-by: Chen Yu <yu.c.chen@intel.com>
1 parent 60943bb commit b989bc0

1 file changed

Lines changed: 6 additions & 16 deletions

File tree

drivers/cpufreq/intel_pstate.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,9 +2195,8 @@ static void intel_pstate_update_perf_limits(struct cpudata *cpu,
21952195
unsigned int policy_min,
21962196
unsigned int policy_max)
21972197
{
2198+
int scaling = cpu->pstate.scaling;
21982199
int32_t max_policy_perf, min_policy_perf;
2199-
int max_state, turbo_max;
2200-
int max_freq;
22012200

22022201
/*
22032202
* HWP needs some special consideration, because HWP_REQUEST uses
@@ -2206,33 +2205,24 @@ static void intel_pstate_update_perf_limits(struct cpudata *cpu,
22062205
if (hwp_active)
22072206
intel_pstate_get_hwp_cap(cpu);
22082207

2209-
if (global.no_turbo || global.turbo_disabled) {
2210-
max_state = cpu->pstate.max_pstate;
2211-
max_freq = cpu->pstate.max_freq;
2212-
} else {
2213-
max_state = cpu->pstate.turbo_pstate;
2214-
max_freq = cpu->pstate.turbo_freq;
2215-
}
2216-
2217-
turbo_max = cpu->pstate.turbo_pstate;
2218-
2219-
max_policy_perf = max_state * policy_max / max_freq;
2208+
max_policy_perf = policy_max / scaling;
22202209
if (policy_max == policy_min) {
22212210
min_policy_perf = max_policy_perf;
22222211
} else {
2223-
min_policy_perf = max_state * policy_min / max_freq;
2212+
min_policy_perf = policy_min / scaling;
22242213
min_policy_perf = clamp_t(int32_t, min_policy_perf,
22252214
0, max_policy_perf);
22262215
}
22272216

2228-
pr_debug("cpu:%d max_state %d min_policy_perf:%d max_policy_perf:%d\n",
2229-
cpu->cpu, max_state, min_policy_perf, max_policy_perf);
2217+
pr_debug("cpu:%d min_policy_perf:%d max_policy_perf:%d\n",
2218+
cpu->cpu, min_policy_perf, max_policy_perf);
22302219

22312220
/* Normalize user input to [min_perf, max_perf] */
22322221
if (per_cpu_limits) {
22332222
cpu->min_perf_ratio = min_policy_perf;
22342223
cpu->max_perf_ratio = max_policy_perf;
22352224
} else {
2225+
int turbo_max = cpu->pstate.turbo_pstate;
22362226
int32_t global_min, global_max;
22372227

22382228
/* Global limits are in percent of the maximum turbo P-state. */

0 commit comments

Comments
 (0)