This brings amd initialization behavior closer to that of acpi.^^^
Signed-off-by: Tejun Heo<tj@xxxxxxxxxx>
Cc: Yinghai Lu<yinghai@xxxxxxxxxx>
Cc: Brian Gerst<brgerst@xxxxxxxxx>
Cc: Cyrill Gorcunov<gorcunov@xxxxxxxxx>
Cc: Shaohui Zheng<shaohui.zheng@xxxxxxxxx>
Cc: David Rientjes<rientjes@xxxxxxxxxx>
Cc: Ingo Molnar<mingo@xxxxxxx>
Cc: H. Peter Anvin<hpa@xxxxxxxxxxxxxxx>
---
arch/x86/mm/amdtopology_64.c | 40 ++++++++++++++++++++++------------------
1 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/arch/x86/mm/amdtopology_64.c b/arch/x86/mm/amdtopology_64.c
index c5eddfa..4056333 100644
--- a/arch/x86/mm/amdtopology_64.c
+++ b/arch/x86/mm/amdtopology_64.c
@@ -74,8 +74,9 @@ int __init amd_numa_init(void)
unsigned long end = PFN_PHYS(max_pfn);
unsigned numnodes;
unsigned long prevbase;
- int i, nb;
+ int i, j, nb;
u32 nodeid, reg;
+ unsigned int bits, cores, apicid_base;
if (!early_pci_allowed())
return -EINVAL;
@@ -176,6 +177,26 @@ int __init amd_numa_init(void)
if (!nodes_weight(mem_nodes_parsed))
return -ENOENT;
+
+ /*
+ * We seem to have valid NUMA configuration. Map apicids to nodes
+ * using the coreid bits from early_identify_cpu.
+ */
+ bits = boot_cpu_data.x86_coreid_bits;
+ cores = 1<< bits;
+ apicid_base = 0;
+
+ /* get the APIC ID of the BSP early for systems with apicid lifting */
+ early_get_boot_cpu_id();
+ if (boot_cpu_physical_apicid> 0) {
+ pr_info("BSP APIC ID: %02x\n", boot_cpu_physical_apicid);
+ apicid_base = boot_cpu_physical_apicid;
+ }
+
+ for_each_node_mask(i, cpu_nodes_parsed)
+ for (j = apicid_base; j< cores + apicid_base; j++)
+ set_apicid_to_node((i<< bits) + j, i);
+
return 0;
}