Skip to content

Commit 3986a0a

Browse files
ssuthiku-amdKAGA-KOKO
authored andcommitted
x86/CPU/AMD: Derive CPU topology from CPUID function 0xB when available
Derive topology information from Extended Topology Enumeration (CPUID function 0xB) when the information is available. Signed-off-by: Suravee Suthikulpanit <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
1 parent 6c4f5ab commit 3986a0a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

arch/x86/kernel/cpu/amd.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
327327

328328
/* get information required for multi-node processors */
329329
if (boot_cpu_has(X86_FEATURE_TOPOEXT)) {
330+
int err;
330331
u32 eax, ebx, ecx, edx;
331332

332333
cpuid(0x8000001e, &eax, &ebx, &ecx, &edx);
@@ -344,6 +345,14 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
344345
c->x86_max_cores /= smp_num_siblings;
345346
}
346347

348+
/*
349+
* In case leaf B is available, use it to derive
350+
* topology information.
351+
*/
352+
err = detect_extended_topology(c);
353+
if (!err)
354+
c->x86_coreid_bits = get_count_order(c->x86_max_cores);
355+
347356
cacheinfo_amd_init_llc_id(c, cpu, node_id);
348357

349358
} else if (cpu_has(c, X86_FEATURE_NODEID_MSR)) {
@@ -378,7 +387,6 @@ static void amd_detect_cmp(struct cpuinfo_x86 *c)
378387
c->phys_proc_id = c->initial_apicid >> bits;
379388
/* use socket ID also for last level cache */
380389
per_cpu(cpu_llc_id, cpu) = c->phys_proc_id;
381-
amd_get_topology(c);
382390
}
383391

384392
u16 amd_get_nb_id(int cpu)
@@ -821,6 +829,7 @@ static void init_amd(struct cpuinfo_x86 *c)
821829
/* Multi core CPU? */
822830
if (c->extended_cpuid_level >= 0x80000008) {
823831
amd_detect_cmp(c);
832+
amd_get_topology(c);
824833
srat_detect_node(c);
825834
}
826835

0 commit comments

Comments
 (0)