]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - arch/x86/mm/amdtopology_64.c
Merge tag 'v2.6.38' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[mv-sheeva.git] / arch / x86 / mm / amdtopology_64.c
similarity index 70%
rename from arch/x86/mm/k8topology_64.c
rename to arch/x86/mm/amdtopology_64.c
index 804a3b6c6e14f6aba0cc36616d85ab882a121685..f21962c435ed78026a41b97d40717a7dc035599c 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * AMD K8 NUMA support.
+ * AMD NUMA support.
  * Discover the memory map and associated nodes.
  *
- * This version reads it directly from the K8 northbridge.
+ * This version reads it directly from the AMD northbridge.
  *
  * Copyright 2002,2003 Andi Kleen, SuSE Labs.
  */
@@ -27,6 +27,7 @@
 #include <asm/amd_nb.h>
 
 static struct bootnode __initdata nodes[8];
+static unsigned char __initdata nodeids[8];
 static nodemask_t __initdata nodes_parsed = NODE_MASK_NONE;
 
 static __init int find_northbridge(void)
@@ -57,7 +58,7 @@ static __init void early_get_boot_cpu_id(void)
 {
        /*
         * need to get the APIC ID of the BSP so can use that to
-        * create apicid_to_node in k8_scan_nodes()
+        * create apicid_to_node in amd_scan_nodes()
         */
 #ifdef CONFIG_X86_MPPARSE
        /*
@@ -66,23 +67,9 @@ static __init void early_get_boot_cpu_id(void)
        if (smp_found_config)
                early_get_smp_config();
 #endif
-       early_init_lapic_mapping();
 }
 
-int __init k8_get_nodes(struct bootnode *physnodes)
-{
-       int i;
-       int ret = 0;
-
-       for_each_node_mask(i, nodes_parsed) {
-               physnodes[ret].start = nodes[i].start;
-               physnodes[ret].end = nodes[i].end;
-               ret++;
-       }
-       return ret;
-}
-
-int __init k8_numa_init(unsigned long start_pfn, unsigned long end_pfn)
+int __init amd_numa_init(unsigned long start_pfn, unsigned long end_pfn)
 {
        unsigned long start = PFN_PHYS(start_pfn);
        unsigned long end = PFN_PHYS(end_pfn);
@@ -114,7 +101,7 @@ int __init k8_numa_init(unsigned long start_pfn, unsigned long end_pfn)
                base = read_pci_config(0, nb, 1, 0x40 + i*8);
                limit = read_pci_config(0, nb, 1, 0x44 + i*8);
 
-               nodeid = limit & 7;
+               nodeids[i] = nodeid = limit & 7;
                if ((base & 3) == 0) {
                        if (i < numnodes)
                                pr_info("Skipping disabled node %d\n", i);
@@ -194,7 +181,77 @@ int __init k8_numa_init(unsigned long start_pfn, unsigned long end_pfn)
        return 0;
 }
 
-int __init k8_scan_nodes(void)
+#ifdef CONFIG_NUMA_EMU
+static s16 fake_apicid_to_node[MAX_LOCAL_APIC] __initdata = {
+       [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE
+};
+
+void __init amd_get_nodes(struct bootnode *physnodes)
+{
+       int i;
+
+       for_each_node_mask(i, nodes_parsed) {
+               physnodes[i].start = nodes[i].start;
+               physnodes[i].end = nodes[i].end;
+       }
+}
+
+static int __init find_node_by_addr(unsigned long addr)
+{
+       int ret = NUMA_NO_NODE;
+       int i;
+
+       for (i = 0; i < 8; i++)
+               if (addr >= nodes[i].start && addr < nodes[i].end) {
+                       ret = i;
+                       break;
+               }
+       return ret;
+}
+
+/*
+ * For NUMA emulation, fake proximity domain (_PXM) to node id mappings must be
+ * setup to represent the physical topology but reflect the emulated
+ * environment.  For each emulated node, the real node which it appears on is
+ * found and a fake pxm to nid mapping is created which mirrors the actual
+ * locality.  node_distance() then represents the correct distances between
+ * emulated nodes by using the fake acpi mappings to pxms.
+ */
+void __init amd_fake_nodes(const struct bootnode *nodes, int nr_nodes)
+{
+       unsigned int bits;
+       unsigned int cores;
+       unsigned int apicid_base = 0;
+       int i;
+
+       bits = boot_cpu_data.x86_coreid_bits;
+       cores = 1 << bits;
+       early_get_boot_cpu_id();
+       if (boot_cpu_physical_apicid > 0)
+               apicid_base = boot_cpu_physical_apicid;
+
+       for (i = 0; i < nr_nodes; i++) {
+               int index;
+               int nid;
+               int j;
+
+               nid = find_node_by_addr(nodes[i].start);
+               if (nid == NUMA_NO_NODE)
+                       continue;
+
+               index = nodeids[nid] << bits;
+               if (fake_apicid_to_node[index + apicid_base] == NUMA_NO_NODE)
+                       for (j = apicid_base; j < cores + apicid_base; j++)
+                               fake_apicid_to_node[index + j] = i;
+#ifdef CONFIG_ACPI_NUMA
+               __acpi_map_pxm_to_node(nid, i);
+#endif
+       }
+       memcpy(apicid_to_node, fake_apicid_to_node, sizeof(apicid_to_node));
+}
+#endif /* CONFIG_NUMA_EMU */
+
+int __init amd_scan_nodes(void)
 {
        unsigned int bits;
        unsigned int cores;