Skip to content

Commit 3eef25a

Browse files
superm1bp3tk0v
authored andcommitted
x86/amd: Use heterogeneous core topology for identifying boost numerator
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 <[email protected]> Signed-off-by: Mario Limonciello <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 45239ba commit 3eef25a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

arch/x86/kernel/acpi/cppc.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,10 @@ EXPORT_SYMBOL_GPL(amd_detect_prefcore);
234234
*/
235235
int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator)
236236
{
237+
enum x86_topology_cpu_type core_type = get_topology_cpu_type(&cpu_data(cpu));
237238
bool prefcore;
238239
int ret;
240+
u32 tmp;
239241

240242
ret = amd_detect_prefcore(&prefcore);
241243
if (ret)
@@ -261,6 +263,27 @@ int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator)
261263
break;
262264
}
263265
}
266+
267+
/* detect if running on heterogeneous design */
268+
if (cpu_feature_enabled(X86_FEATURE_AMD_HETEROGENEOUS_CORES)) {
269+
switch (core_type) {
270+
case TOPO_CPU_TYPE_UNKNOWN:
271+
pr_warn("Undefined core type found for cpu %d\n", cpu);
272+
break;
273+
case TOPO_CPU_TYPE_PERFORMANCE:
274+
/* use the max scale for performance cores */
275+
*numerator = CPPC_HIGHEST_PERF_PERFORMANCE;
276+
return 0;
277+
case TOPO_CPU_TYPE_EFFICIENCY:
278+
/* use the highest perf value for efficiency cores */
279+
ret = amd_get_highest_perf(cpu, &tmp);
280+
if (ret)
281+
return ret;
282+
*numerator = tmp;
283+
return 0;
284+
}
285+
}
286+
264287
*numerator = CPPC_HIGHEST_PERF_PREFCORE;
265288

266289
return 0;

0 commit comments

Comments
 (0)