Skip to content

Commit a158bed

Browse files
Philippe Longeperafaeljw
authored andcommitted
intel_pstate: Optimize calculation for max/min_perf_adj
mul_fp(int_tofp(A), B) expands to: ((A << FRAC_BITS) * B) >> FRAC_BITS, so the same result can be obtained via simple multiplication A * B. Apply this observation to max_perf * limits->max_perf and max_perf * limits->min_perf in intel_pstate_get_min_max()." Signed-off-by: Philippe Longepe <philippe.longepe@linux.intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent b54a0df commit a158bed

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/cpufreq/intel_pstate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,11 +831,11 @@ static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max)
831831
* policy, or by cpu specific default values determined through
832832
* experimentation.
833833
*/
834-
max_perf_adj = fp_toint(mul_fp(int_tofp(max_perf), limits->max_perf));
834+
max_perf_adj = fp_toint(max_perf * limits->max_perf);
835835
*max = clamp_t(int, max_perf_adj,
836836
cpu->pstate.min_pstate, cpu->pstate.turbo_pstate);
837837

838-
min_perf = fp_toint(mul_fp(int_tofp(max_perf), limits->min_perf));
838+
min_perf = fp_toint(max_perf * limits->min_perf);
839839
*min = clamp_t(int, min_perf, cpu->pstate.min_pstate, max_perf);
840840
}
841841

0 commit comments

Comments
 (0)