aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2017-02-03 17:18:39 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-02-03 18:11:08 -0500
commit6e978b22efa1db9f6e71b24440b5f1d93e968ee3 (patch)
treec666f7a26b860674848949e39a610222b0723f89
parent3c223c19aea85d3dda1416c187915f4a30b04b1f (diff)
cpufreq: intel_pstate: Disable energy efficiency optimization
Some Kabylake desktop processors may not reach max turbo when running in HWP mode, even if running under sustained 100% utilization. This occurs when the HWP.EPP (Energy Performance Preference) is set to "balance_power" (0x80) -- the default on most systems. It occurs because the platform BIOS may erroneously enable an energy-efficiency setting -- MSR_IA32_POWER_CTL BIT-EE, which is not recommended to be enabled on this SKU. On the failing systems, this BIOS issue was not discovered when the desktop motherboard was tested with Windows, because the BIOS also neglects to provide the ACPI/CPPC table, that Windows requires to enable HWP, and so Windows runs in legacy P-state mode, where this setting has no effect. Linux' intel_pstate driver does not require ACPI/CPPC to enable HWP, and so it runs in HWP mode, exposing this incorrect BIOS configuration. There are several ways to address this problem. First, Linux can also run in legacy P-state mode on this system. As intel_pstate is how Linux enables HWP, booting with "intel_pstate=disable" will run in acpi-cpufreq/ondemand legacy p-state mode. Or second, the "performance" governor can be used with intel_pstate, which will modify HWP.EPP to 0. Or third, starting in 4.10, the /sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference attribute in can be updated from "balance_power" to "performance". Or fourth, apply this patch, which fixes the erroneous setting of MSR_IA32_POWER_CTL BIT_EE on this model, allowing the default configuration to function as designed. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Reviewed-by: Len Brown <len.brown@intel.com> Cc: 4.6+ <stable@vger.kernel.org> # 4.6+ Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/cpufreq/intel_pstate.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index f91c25718d16..86e36544925f 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1235,6 +1235,25 @@ static void intel_pstate_hwp_enable(struct cpudata *cpudata)
1235 cpudata->epp_default = intel_pstate_get_epp(cpudata, 0); 1235 cpudata->epp_default = intel_pstate_get_epp(cpudata, 0);
1236} 1236}
1237 1237
1238#define MSR_IA32_POWER_CTL_BIT_EE 19
1239
1240/* Disable energy efficiency optimization */
1241static void intel_pstate_disable_ee(int cpu)
1242{
1243 u64 power_ctl;
1244 int ret;
1245
1246 ret = rdmsrl_on_cpu(cpu, MSR_IA32_POWER_CTL, &power_ctl);
1247 if (ret)
1248 return;
1249
1250 if (!(power_ctl & BIT(MSR_IA32_POWER_CTL_BIT_EE))) {
1251 pr_info("Disabling energy efficiency optimization\n");
1252 power_ctl |= BIT(MSR_IA32_POWER_CTL_BIT_EE);
1253 wrmsrl_on_cpu(cpu, MSR_IA32_POWER_CTL, power_ctl);
1254 }
1255}
1256
1238static int atom_get_min_pstate(void) 1257static int atom_get_min_pstate(void)
1239{ 1258{
1240 u64 value; 1259 u64 value;
@@ -1845,6 +1864,11 @@ static const struct x86_cpu_id intel_pstate_cpu_oob_ids[] __initconst = {
1845 {} 1864 {}
1846}; 1865};
1847 1866
1867static const struct x86_cpu_id intel_pstate_cpu_ee_disable_ids[] = {
1868 ICPU(INTEL_FAM6_KABYLAKE_DESKTOP, core_params),
1869 {}
1870};
1871
1848static int intel_pstate_init_cpu(unsigned int cpunum) 1872static int intel_pstate_init_cpu(unsigned int cpunum)
1849{ 1873{
1850 struct cpudata *cpu; 1874 struct cpudata *cpu;
@@ -1875,6 +1899,12 @@ static int intel_pstate_init_cpu(unsigned int cpunum)
1875 cpu->cpu = cpunum; 1899 cpu->cpu = cpunum;
1876 1900
1877 if (hwp_active) { 1901 if (hwp_active) {
1902 const struct x86_cpu_id *id;
1903
1904 id = x86_match_cpu(intel_pstate_cpu_ee_disable_ids);
1905 if (id)
1906 intel_pstate_disable_ee(cpunum);
1907
1878 intel_pstate_hwp_enable(cpu); 1908 intel_pstate_hwp_enable(cpu);
1879 pid_params.sample_rate_ms = 50; 1909 pid_params.sample_rate_ms = 50;
1880 pid_params.sample_rate_ns = 50 * NSEC_PER_MSEC; 1910 pid_params.sample_rate_ns = 50 * NSEC_PER_MSEC;