public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/apic: Fix CPU devicetree-node lookups
@ 2020-11-24 13:42 Johan Hovold
  2020-12-08 10:05 ` Johan Hovold
  0 siblings, 1 reply; 4+ messages in thread
From: Johan Hovold @ 2020-11-24 13:42 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Ingo Molnar, Borislav Petkov, x86, H. Peter Anvin, Rob Herring,
	linux-kernel, Johan Hovold

Fix CPU devicetree-node lookups by implementing
arch_match_cpu_phys_id().

This allows using of_get_cpu_node() and of_cpu_device_node_get() to look
up CPU devicetree nodes and specifically makes sure that CPU struct
devices are linked to the correct devicetree nodes.

Note that CPUs are described in devicetree using their APIC ids and
that those do not generally coincide with the logical ids (e.g. used by
the default arch_match_cpu_phys_id() implementation).

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 arch/x86/kernel/apic/apic.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index b3eef1d5c903..19c0119892dd 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2311,6 +2311,11 @@ static int cpuid_to_apicid[] = {
 	[0 ... NR_CPUS - 1] = -1,
 };
 
+bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
+{
+	return phys_id == cpuid_to_apicid[cpu];
+}
+
 #ifdef CONFIG_SMP
 /**
  * apic_id_is_primary_thread - Check whether APIC ID belongs to a primary thread
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-09 13:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-24 13:42 [PATCH] x86/apic: Fix CPU devicetree-node lookups Johan Hovold
2020-12-08 10:05 ` Johan Hovold
2020-12-09  2:19   ` Thomas Gleixner
2020-12-09 13:38     ` Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox