diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2017-03-27 18:24:26 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2017-03-28 17:12:17 -0400 |
commit | b02aabe8ab9757a7dd5aa50e201a6d970f7e7a2f (patch) | |
tree | 6e05a7ec23661adf1f79c943af57c1909278f9f5 | |
parent | 2bfc4cbb5fd3848669f1b95fea793f63d8e77fa0 (diff) |
cpufreq: intel_pstate: Eliminate intel_pstate_get_min_max()
Some computations in intel_pstate_get_min_max() are not necessary
and one of its two callers doesn't even use the full result.
First off, the fixed-point value of cpu->max_perf represents a
non-negative number between 0 and 1 inclusive and cpu->min_perf
cannot be greater than cpu->max_perf. It is not necessary to check
those conditions every time the numbers in question are used.
Moreover, since intel_pstate_max_within_limits() only needs the
upper boundary, it doesn't make sense to compute the lower one in
there and returning min and max from intel_pstate_get_min_max()
via pointers doesn't look particularly nice.
For the above reasons, drop intel_pstate_get_min_max(), add a helper
to get the base P-state for min/max computations and carry out them
directly in the previous callers of intel_pstate_get_min_max().
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/cpufreq/intel_pstate.c | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 5236701958d0..b62daf5a4ee8 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -1496,26 +1496,10 @@ static int knl_get_turbo_pstate(void) | |||
1496 | return ret; | 1496 | return ret; |
1497 | } | 1497 | } |
1498 | 1498 | ||
1499 | static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max) | 1499 | static int intel_pstate_get_base_pstate(struct cpudata *cpu) |
1500 | { | 1500 | { |
1501 | int max_perf = cpu->pstate.turbo_pstate; | 1501 | return global.no_turbo || global.turbo_disabled ? |
1502 | int max_perf_adj; | 1502 | cpu->pstate.max_pstate : cpu->pstate.turbo_pstate; |
1503 | int min_perf; | ||
1504 | |||
1505 | if (global.no_turbo || global.turbo_disabled) | ||
1506 | max_perf = cpu->pstate.max_pstate; | ||
1507 | |||
1508 | /* | ||
1509 | * performance can be limited by user through sysfs, by cpufreq | ||
1510 | * policy, or by cpu specific default values determined through | ||
1511 | * experimentation. | ||
1512 | */ | ||
1513 | max_perf_adj = fp_ext_toint(max_perf * cpu->max_perf); | ||
1514 | *max = clamp_t(int, max_perf_adj, | ||
1515 | cpu->pstate.min_pstate, cpu->pstate.turbo_pstate); | ||
1516 | |||
1517 | min_perf = fp_ext_toint(max_perf * cpu->min_perf); | ||
1518 | *min = clamp_t(int, min_perf, cpu->pstate.min_pstate, max_perf); | ||
1519 | } | 1503 | } |
1520 | 1504 | ||
1521 | static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate) | 1505 | static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate) |
@@ -1538,11 +1522,13 @@ static void intel_pstate_set_min_pstate(struct cpudata *cpu) | |||
1538 | 1522 | ||
1539 | static void intel_pstate_max_within_limits(struct cpudata *cpu) | 1523 | static void intel_pstate_max_within_limits(struct cpudata *cpu) |
1540 | { | 1524 | { |
1541 | int min_pstate, max_pstate; | 1525 | int pstate; |
1542 | 1526 | ||
1543 | update_turbo_state(); | 1527 | update_turbo_state(); |
1544 | intel_pstate_get_min_max(cpu, &min_pstate, &max_pstate); | 1528 | pstate = intel_pstate_get_base_pstate(cpu); |
1545 | intel_pstate_set_pstate(cpu, max_pstate); | 1529 | pstate = max(cpu->pstate.min_pstate, |
1530 | fp_ext_toint(pstate * cpu->max_perf)); | ||
1531 | intel_pstate_set_pstate(cpu, pstate); | ||
1546 | } | 1532 | } |
1547 | 1533 | ||
1548 | static void intel_pstate_get_cpu_pstates(struct cpudata *cpu) | 1534 | static void intel_pstate_get_cpu_pstates(struct cpudata *cpu) |
@@ -1704,11 +1690,13 @@ static inline int32_t get_target_pstate_use_performance(struct cpudata *cpu) | |||
1704 | 1690 | ||
1705 | static int intel_pstate_prepare_request(struct cpudata *cpu, int pstate) | 1691 | static int intel_pstate_prepare_request(struct cpudata *cpu, int pstate) |
1706 | { | 1692 | { |
1707 | int max_perf, min_perf; | 1693 | int max_pstate = intel_pstate_get_base_pstate(cpu); |
1694 | int min_pstate; | ||
1708 | 1695 | ||
1709 | intel_pstate_get_min_max(cpu, &min_perf, &max_perf); | 1696 | min_pstate = max(cpu->pstate.min_pstate, |
1710 | pstate = clamp_t(int, pstate, min_perf, max_perf); | 1697 | fp_ext_toint(max_pstate * cpu->min_perf)); |
1711 | return pstate; | 1698 | max_pstate = max(min_pstate, fp_ext_toint(max_pstate * cpu->max_perf)); |
1699 | return clamp_t(int, pstate, min_pstate, max_pstate); | ||
1712 | } | 1700 | } |
1713 | 1701 | ||
1714 | static void intel_pstate_update_pstate(struct cpudata *cpu, int pstate) | 1702 | static void intel_pstate_update_pstate(struct cpudata *cpu, int pstate) |