]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/amd: Use heterogeneous core topology for identifying boost numerator
authorMario Limonciello <mario.limonciello@amd.com>
Fri, 25 Oct 2024 17:14:59 +0000 (12:14 -0500)
committerBorislav Petkov (AMD) <bp@alien8.de>
Fri, 25 Oct 2024 18:51:17 +0000 (20:51 +0200)
AMD heterogeneous designs include two types of cores:

 * Performance
 * Efficiency

Each core type has different highest performance values configured by the
platform.  Drivers such as amd_pstate need to identify the type of core to
correctly set an appropriate boost numerator to calculate the maximum
frequency.

X86_FEATURE_AMD_HETEROGENEOUS_CORES is used to identify whether the SoC
supports heterogeneous core type by reading CPUID leaf Fn_0x80000026.

On performance cores the scaling factor of 196 is used.  On efficiency cores
the scaling factor is the value reported as the highest perf.  Efficiency
cores have the same preferred core rankings.

Suggested-by: Perry Yuan <perry.yuan@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20241025171459.1093-6-mario.limonciello@amd.com
arch/x86/kernel/acpi/cppc.c

index 956984054bf300494c687a10cc3e14953a0ae215..59edf64ad9edc4ed923868cf390d84f29d6a4a07 100644 (file)
@@ -234,8 +234,10 @@ EXPORT_SYMBOL_GPL(amd_detect_prefcore);
  */
 int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator)
 {
+       enum x86_topology_cpu_type core_type = get_topology_cpu_type(&cpu_data(cpu));
        bool prefcore;
        int ret;
+       u32 tmp;
 
        ret = amd_detect_prefcore(&prefcore);
        if (ret)
@@ -261,6 +263,27 @@ int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator)
                        break;
                }
        }
+
+       /* detect if running on heterogeneous design */
+       if (cpu_feature_enabled(X86_FEATURE_AMD_HETEROGENEOUS_CORES)) {
+               switch (core_type) {
+               case TOPO_CPU_TYPE_UNKNOWN:
+                       pr_warn("Undefined core type found for cpu %d\n", cpu);
+                       break;
+               case TOPO_CPU_TYPE_PERFORMANCE:
+                       /* use the max scale for performance cores */
+                       *numerator = CPPC_HIGHEST_PERF_PERFORMANCE;
+                       return 0;
+               case TOPO_CPU_TYPE_EFFICIENCY:
+                       /* use the highest perf value for efficiency cores */
+                       ret = amd_get_highest_perf(cpu, &tmp);
+                       if (ret)
+                               return ret;
+                       *numerator = tmp;
+                       return 0;
+               }
+       }
+
        *numerator = CPPC_HIGHEST_PERF_PREFCORE;
 
        return 0;