Skip to content

Commit dd92688

Browse files
jhovoldKAGA-KOKO
authored andcommitted
x86/apic/of: Fix CPU devicetree-node lookups
Architectures that describe the CPU topology in devicetree and do not have an identity mapping between physical and logical CPU ids must override the default implementation of arch_match_cpu_phys_id(). Failing to do so breaks CPU devicetree-node lookups using of_get_cpu_node() and of_cpu_device_node_get() which several drivers rely on. It also causes the CPU struct devices exported through sysfs to point to the wrong devicetree nodes. On x86, CPUs are described in devicetree using their APIC ids and those do not generally coincide with the logical ids, even if CPU0 typically uses APIC id 0. Add the missing implementation of arch_match_cpu_phys_id() so that CPU-node lookups work also with SMP. Apart from fixing the broken sysfs devicetree-node links this likely does not affect current users of mainline kernels on x86. Fixes: 4e07db9 ("x86/devicetree: Use CPU description from Device Tree") Signed-off-by: Johan Hovold <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a501b04 commit dd92688

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

arch/x86/kernel/apic/apic.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,6 +2342,11 @@ static int cpuid_to_apicid[] = {
23422342
[0 ... NR_CPUS - 1] = -1,
23432343
};
23442344

2345+
bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
2346+
{
2347+
return phys_id == cpuid_to_apicid[cpu];
2348+
}
2349+
23452350
#ifdef CONFIG_SMP
23462351
/**
23472352
* apic_id_is_primary_thread - Check whether APIC ID belongs to a primary thread

0 commit comments

Comments
 (0)