Skip to contentSkip to conversation

cpufreq: intel_pstate: Fix cpuinfo_max_freq when MSR_TURBO_RATIO_LIMIT is 0

PATCH Applied Srinivas Pandruvada 2 participants 2 messages Aug 3, 2020 – Aug 4, 2020

Subsystems (2)
lore
Share & tools
lore

Srinivas Pandruvada

author maintainer
#0 lore raw

PATCH 1/1 cpufreq: intel_pstate: Fix cpuinfo_max_freq when MSR_TURBO_RATIO_LIMIT is 0

The MSR_TURBO_RATIO_LIMIT can be 0. This is not an error. User can update this MSR via BIOS settings on some systems or can use msr tools to update. Also some systems boot with value = 0.

This results in display of cpufreq/cpuinfo_max_freq wrong. This value will be equal to cpufreq/base_frequency, even though turbo is enabled.

But platform will still function normally in HWP mode as we get max 1-core frequency from the MSR_HWP_CAPABILITIES. This MSR is already used to calculate cpu->pstate.turbo_freq, which is used for to set policy->cpuinfo.max_freq. But some other places cpu->pstate.turbo_pstate is used. For example to set policy->max.

To fix this, also update cpu->pstate.turbo_pstate when updating cpu->pstate.turbo_freq.

---
 drivers/cpufreq/intel_pstate.c | 1 +
 1 file changed, 1 insertion(+)
drivers/cpufreq/intel_pstate.c +1 -0
index 7e0f7880b21a..c7540ad28995 100644
@@ -1572,6 +1572,7 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
 
 		intel_pstate_get_hwp_max(cpu->cpu, &phy_max, &current_max);
 		cpu->pstate.turbo_freq = phy_max * cpu->pstate.scaling;
+		cpu->pstate.turbo_pstate = phy_max;
 	} else {
 		cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * cpu->pstate.scaling;
 	}
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 14 lines · Srinivas Pandruvada

The MSR_TURBO_RATIO_LIMIT can be 0. This is not an error. User can update this MSR via BIOS settings on some systems or can use msr tools to update. Also some systems boot with value = 0.

This results in display of cpufreq/cpuinfo_max_freq wrong. This value will be equal to cpufreq/base_frequency, even though turbo is enabled.

But platform will still function normally in HWP mode as we get max 1-core frequency from the MSR_HWP_CAPABILITIES. This MSR is already used to calculate cpu->pstate.turbo_freq, which is used for to set policy->cpuinfo.max_freq. But some other places cpu->pstate.turbo_pstate is used. For example to set policy->max.

Quoted 4 lines

To fix this, also update cpu->pstate.turbo_pstate when updating cpu->pstate.turbo_freq.

Applied as a fix for 5.9-rc1, thanks!

Quoted 19 lines
---
 drivers/cpufreq/intel_pstate.c | 1 +
 1 file changed, 1 insertion(+)
drivers/cpufreq/intel_pstate.c +1 -1
index 7e0f7880b21a..c7540ad28995 100644
@@ -1572,6 +1572,7 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
 
                intel_pstate_get_hwp_max(cpu->cpu, &phy_max, &current_max);
                cpu->pstate.turbo_freq = phy_max * cpu->pstate.scaling;
+               cpu->pstate.turbo_pstate = phy_max;
        } else {
                cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * cpu->pstate.scaling;
        }
--

2.17.1