Re: [PATCH] x86/apic: Fix CPU devicetree-node lookups

From: Johan Hovold
Date: Tue Dec 08 2020 - 05:05:44 EST


On Tue, Nov 24, 2020 at 02:42:47PM +0100, Johan Hovold wrote:
> 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@xxxxxxxxxx>
> ---
> 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

Any comments to this one? Can it be picked up for 5.11?

Johan