diff options
author | Len Brown <len.brown@intel.com> | 2017-05-01 23:06:08 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2017-05-11 21:27:53 -0400 |
commit | 3cedbc5a6d7f7c5539e139f89ec9f6e1ed668418 (patch) | |
tree | a00534027c4ac7a238791527a0a9ccc810ab87e9 | |
parent | 4beec1d7519691b4b6c6b764e75b4e694a09c5f7 (diff) |
intel_pstate: use updated msr-index.h HWP.EPP values
intel_pstate exports sysfs attributes for setting and observing HWP.EPP.
These attributes use strings to describe 4 operating states, and
inside the driver, these strings are mapped to numerical register
values.
The authorative mapping between the strings and numerical HWP.EPP values
are now globally defined in msr-index.h, replacing the out-dated
mapping that were open-coded into intel_pstate.c
new old string
--- --- ------
0 0 performance
128 64 balance_performance
192 128 balance_power
255 192 power
Note that the HW and BIOS default value on most system is 128,
which intel_pstate will now call "balance_performance"
while it used to call it "balance_power".
Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r-- | drivers/cpufreq/intel_pstate.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 50bd6d987fc3..ab8ebaeb3621 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -716,6 +716,12 @@ static const char * const energy_perf_strings[] = { | |||
716 | "power", | 716 | "power", |
717 | NULL | 717 | NULL |
718 | }; | 718 | }; |
719 | static const unsigned int epp_values[] = { | ||
720 | HWP_EPP_PERFORMANCE, | ||
721 | HWP_EPP_BALANCE_PERFORMANCE, | ||
722 | HWP_EPP_BALANCE_POWERSAVE, | ||
723 | HWP_EPP_POWERSAVE | ||
724 | }; | ||
719 | 725 | ||
720 | static int intel_pstate_get_energy_pref_index(struct cpudata *cpu_data) | 726 | static int intel_pstate_get_energy_pref_index(struct cpudata *cpu_data) |
721 | { | 727 | { |
@@ -727,17 +733,14 @@ static int intel_pstate_get_energy_pref_index(struct cpudata *cpu_data) | |||
727 | return epp; | 733 | return epp; |
728 | 734 | ||
729 | if (static_cpu_has(X86_FEATURE_HWP_EPP)) { | 735 | if (static_cpu_has(X86_FEATURE_HWP_EPP)) { |
730 | /* | 736 | if (epp == HWP_EPP_PERFORMANCE) |
731 | * Range: | 737 | return 1; |
732 | * 0x00-0x3F : Performance | 738 | if (epp <= HWP_EPP_BALANCE_PERFORMANCE) |
733 | * 0x40-0x7F : Balance performance | 739 | return 2; |
734 | * 0x80-0xBF : Balance power | 740 | if (epp <= HWP_EPP_BALANCE_POWERSAVE) |
735 | * 0xC0-0xFF : Power | 741 | return 3; |
736 | * The EPP is a 8 bit value, but our ranges restrict the | 742 | else |
737 | * value which can be set. Here only using top two bits | 743 | return 4; |
738 | * effectively. | ||
739 | */ | ||
740 | index = (epp >> 6) + 1; | ||
741 | } else if (static_cpu_has(X86_FEATURE_EPB)) { | 744 | } else if (static_cpu_has(X86_FEATURE_EPB)) { |
742 | /* | 745 | /* |
743 | * Range: | 746 | * Range: |
@@ -775,15 +778,8 @@ static int intel_pstate_set_energy_pref_index(struct cpudata *cpu_data, | |||
775 | 778 | ||
776 | value &= ~GENMASK_ULL(31, 24); | 779 | value &= ~GENMASK_ULL(31, 24); |
777 | 780 | ||
778 | /* | ||
779 | * If epp is not default, convert from index into | ||
780 | * energy_perf_strings to epp value, by shifting 6 | ||
781 | * bits left to use only top two bits in epp. | ||
782 | * The resultant epp need to shifted by 24 bits to | ||
783 | * epp position in MSR_HWP_REQUEST. | ||
784 | */ | ||
785 | if (epp == -EINVAL) | 781 | if (epp == -EINVAL) |
786 | epp = (pref_index - 1) << 6; | 782 | epp = epp_values[pref_index - 1]; |
787 | 783 | ||
788 | value |= (u64)epp << 24; | 784 | value |= (u64)epp << 24; |
789 | ret = wrmsrl_on_cpu(cpu_data->cpu, MSR_HWP_REQUEST, value); | 785 | ret = wrmsrl_on_cpu(cpu_data->cpu, MSR_HWP_REQUEST, value); |