Skip to content

Commit 6e978b2

Browse files
spandruvadarafaeljw
authored andcommitted
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 <[email protected]> Reviewed-by: Len Brown <[email protected]> Cc: 4.6+ <[email protected]> # 4.6+ Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 3c223c1 commit 6e978b2

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

drivers/cpufreq/intel_pstate.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,25 @@ static void intel_pstate_hwp_enable(struct cpudata *cpudata)
12351235
cpudata->epp_default = intel_pstate_get_epp(cpudata, 0);
12361236
}
12371237

1238+
#define MSR_IA32_POWER_CTL_BIT_EE 19
1239+
1240+
/* Disable energy efficiency optimization */
1241+
static 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+
12381257
static int atom_get_min_pstate(void)
12391258
{
12401259
u64 value;
@@ -1845,6 +1864,11 @@ static const struct x86_cpu_id intel_pstate_cpu_oob_ids[] __initconst = {
18451864
{}
18461865
};
18471866

1867+
static const struct x86_cpu_id intel_pstate_cpu_ee_disable_ids[] = {
1868+
ICPU(INTEL_FAM6_KABYLAKE_DESKTOP, core_params),
1869+
{}
1870+
};
1871+
18481872
static int intel_pstate_init_cpu(unsigned int cpunum)
18491873
{
18501874
struct cpudata *cpu;
@@ -1875,6 +1899,12 @@ static int intel_pstate_init_cpu(unsigned int cpunum)
18751899
cpu->cpu = cpunum;
18761900

18771901
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+
18781908
intel_pstate_hwp_enable(cpu);
18791909
pid_params.sample_rate_ms = 50;
18801910
pid_params.sample_rate_ns = 50 * NSEC_PER_MSEC;

0 commit comments

Comments
 (0)