]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
cpufreq: intel_pstate: Get per-CPU max freq via MSR_HWP_CAPABILITIES if available
authorChen Yu <yu.c.chen@intel.com>
Tue, 12 Jan 2021 05:21:27 +0000 (13:21 +0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Apr 2021 16:31:41 +0000 (18:31 +0200)
BugLink: https://bugs.launchpad.net/bugs/1918974
commit 6f67e060083a84a4cc364eab6ae40c717165fb0c upstream.

Currently, when turbo is disabled (either by BIOS or by the user),
the intel_pstate driver reads the max non-turbo frequency from the
package-wide MSR_PLATFORM_INFO(0xce) register.

However, on asymmetric platforms it is possible in theory that small
and big core with HWP enabled might have different max non-turbo CPU
frequency, because MSR_HWP_CAPABILITIES is per-CPU scope according
to Intel Software Developer Manual.

The turbo max freq is already per-CPU in current code, so make
similar change to the max non-turbo frequency as well.

Reported-by: Wendy Wang <wendy.wang@intel.com>
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
[ rjw: Subject and changelog edits ]
Cc: 4.18+ <stable@vger.kernel.org> # 4.18+: a45ee4d4e13b: cpufreq: intel_pstate: Change intel_pstate_get_hwp_max() argument
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
drivers/cpufreq/intel_pstate.c

index b9ca89dc75c7dfbdd2ed595309bc5cb58959262e..88fe803a044d563a8d4f6a92d839523eb8db5f13 100644 (file)
@@ -1566,11 +1566,9 @@ static void intel_pstate_max_within_limits(struct cpudata *cpu)
 static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
 {
        cpu->pstate.min_pstate = pstate_funcs.get_min();
-       cpu->pstate.max_pstate = pstate_funcs.get_max();
        cpu->pstate.max_pstate_physical = pstate_funcs.get_max_physical();
        cpu->pstate.turbo_pstate = pstate_funcs.get_turbo();
        cpu->pstate.scaling = pstate_funcs.get_scaling();
-       cpu->pstate.max_freq = cpu->pstate.max_pstate * cpu->pstate.scaling;
 
        if (hwp_active && !hwp_mode_bdw) {
                unsigned int phy_max, current_max;
@@ -1578,9 +1576,12 @@ 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;
+               cpu->pstate.max_pstate = HWP_GUARANTEED_PERF(READ_ONCE(cpu->hwp_cap_cached));
        } else {
                cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * cpu->pstate.scaling;
+               cpu->pstate.max_pstate = pstate_funcs.get_max();
        }
+       cpu->pstate.max_freq = cpu->pstate.max_pstate * cpu->pstate.scaling;
 
        if (pstate_funcs.get_aperf_mperf_shift)
                cpu->aperf_mperf_shift = pstate_funcs.get_aperf_mperf_shift();