Use the CPU _PXM (Node) relation for disabled CPUs too when parsing SRAT
table. This detail will be used for early topology parsing to count the
LLC domains and set sparsebitmask (sbm) properties correctly.

In addition to sbm enablement, this also helps mapping per-CPU areas
correctly for disabled CPUs by initializing the node relations via
set_cpuid_to_node() correctly and avoiding the "rr_node" based fallback
in smp_prepare_boot_cpu().

Signed-off-by: K Prateek Nayak <[email protected]>
---
 arch/loongarch/kernel/acpi.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c
index cb454ee92b20..1f15f78713b7 100644
--- a/arch/loongarch/kernel/acpi.c
+++ b/arch/loongarch/kernel/acpi.c
@@ -311,8 +311,7 @@ acpi_numa_processor_affinity_init(struct 
acpi_srat_cpu_affinity *pa)
                bad_srat();
                return;
        }
-       if ((pa->flags & ACPI_SRAT_CPU_ENABLED) == 0)
-               return;
+
        pxm = pa->proximity_domain_lo;
        if (acpi_srat_revision >= 2) {
                pxm |= (pa->proximity_domain_hi[0] << 8);
@@ -332,9 +331,12 @@ acpi_numa_processor_affinity_init(struct 
acpi_srat_cpu_affinity *pa)
                return;
        }
 
-       early_numa_add_cpu(pa->apic_id, node);
-
        set_cpuid_to_node(pa->apic_id, node);
+
+       if ((pa->flags & ACPI_SRAT_CPU_ENABLED) == 0)
+               return;
+
+       early_numa_add_cpu(pa->apic_id, node);
        node_set(node, numa_nodes_parsed);
        pr_info("SRAT: PXM %u -> CPU 0x%02x -> Node %u\n", pxm, pa->apic_id, 
node);
 }
@@ -350,8 +352,7 @@ acpi_numa_x2apic_affinity_init(struct 
acpi_srat_x2apic_cpu_affinity *pa)
                bad_srat();
                return;
        }
-       if ((pa->flags & ACPI_SRAT_CPU_ENABLED) == 0)
-               return;
+
        pxm = pa->proximity_domain;
        node = acpi_map_pxm_to_node(pxm);
        if (node < 0) {
@@ -366,9 +367,12 @@ acpi_numa_x2apic_affinity_init(struct 
acpi_srat_x2apic_cpu_affinity *pa)
                return;
        }
 
-       early_numa_add_cpu(pa->apic_id, node);
-
        set_cpuid_to_node(pa->apic_id, node);
+
+       if ((pa->flags & ACPI_SRAT_CPU_ENABLED) == 0)
+               return;
+
+       early_numa_add_cpu(pa->apic_id, node);
        node_set(node, numa_nodes_parsed);
        pr_info("SRAT: PXM %u -> CPU 0x%02x -> Node %u\n", pxm, pa->apic_id, 
node);
 }
-- 
2.34.1


Reply via email to