]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] x86-64: Use ACPI PXM to parse PCI<->node assignments
authorAndi Kleen <ak@suse.de>
Mon, 12 Sep 2005 16:49:24 +0000 (18:49 +0200)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 12 Sep 2005 17:49:57 +0000 (10:49 -0700)
Since this is shared code I had to implement it for i386 too

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/i386/kernel/srat.c
arch/i386/pci/acpi.c
arch/x86_64/kernel/mpparse.c
arch/x86_64/mm/srat.c
arch/x86_64/pci/k8-bus.c
include/asm-i386/numa.h [new file with mode: 0644]
include/asm-i386/topology.h
include/asm-x86_64/numa.h
include/asm-x86_64/topology.h

index 7b3b27d64409381a9a557a58b6543feade5e6b9f..516bf5653b0266ea1f4beb9258bd6577c0b3e6ab 100644 (file)
@@ -213,12 +213,18 @@ static __init void node_read_chunk(int nid, struct node_memory_chunk_s *memory_c
                node_end_pfn[nid] = memory_chunk->end_pfn;
 }
 
+static u8 pxm_to_nid_map[MAX_PXM_DOMAINS];/* _PXM to logical node ID map */
+
+int pxm_to_node(int pxm)
+{
+       return pxm_to_nid_map[pxm];
+}
+
 /* Parse the ACPI Static Resource Affinity Table */
 static int __init acpi20_parse_srat(struct acpi_table_srat *sratp)
 {
        u8 *start, *end, *p;
        int i, j, nid;
-       u8 pxm_to_nid_map[MAX_PXM_DOMAINS];/* _PXM to logical node ID map */
        u8 nid_to_pxm_map[MAX_NUMNODES];/* logical node ID to _PXM map */
 
        start = (u8 *)(&(sratp->reserved) + 1); /* skip header */
index 42913f43feb0edca0015a1f2013c609cc361d802..2941674f35eb5aae272a3000edd491993ec1b0aa 100644 (file)
@@ -3,16 +3,31 @@
 #include <linux/init.h>
 #include <linux/irq.h>
 #include <asm/hw_irq.h>
+#include <asm/numa.h>
 #include "pci.h"
 
 struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int domain, int busnum)
 {
+       struct pci_bus *bus;
+
        if (domain != 0) {
                printk(KERN_WARNING "PCI: Multiple domains not supported\n");
                return NULL;
        }
 
-       return pcibios_scan_root(busnum);
+       bus = pcibios_scan_root(busnum);
+#ifdef CONFIG_ACPI_NUMA
+       if (bus != NULL) {
+               int pxm = acpi_get_pxm(device->handle);
+               if (pxm >= 0) {
+                       bus->sysdata = (void *)(unsigned long)pxm_to_node(pxm);
+                       printk("bus %d -> pxm %d -> node %ld\n",
+                               busnum, pxm, (long)(bus->sysdata));
+               }
+       }
+#endif
+       
+       return bus;
 }
 
 extern int pci_routeirq;
index 312ecc9e5f7f0ed99e7023e441f4c85736be6a77..11642526c5b7e0eed61dcfa14f91dcec2096ff40 100644 (file)
@@ -46,8 +46,6 @@ int acpi_found_madt;
 int apic_version [MAX_APICS];
 unsigned char mp_bus_id_to_type [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 };
 int mp_bus_id_to_pci_bus [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 };
-unsigned char pci_bus_to_node [256];
-EXPORT_SYMBOL(pci_bus_to_node);
 
 static int mp_current_pci_id = 0;
 /* I/O APIC entries */
index 92f6ec79b23222ddac8d3bbe382086dd8868ef0a..db6b073a149ffb7bbc4eae0641052e38a4e15c27 100644 (file)
@@ -25,6 +25,13 @@ static nodemask_t nodes_found __initdata;
 static struct node nodes[MAX_NUMNODES] __initdata;
 static __u8  pxm2node[256] = { [0 ... 255] = 0xff };
 
+int pxm_to_node(int pxm)
+{
+       if ((unsigned)pxm >= 256)
+               return 0;
+       return pxm2node[pxm];
+}
+
 static __init int setup_node(int pxm)
 {
        unsigned node = pxm2node[pxm];
index d80c323669e0c5e741a33f8c5700b2c8b8784007..3acf60ded2a0b54144a72b5b0faf5f8bc2c00933 100644 (file)
@@ -58,10 +58,16 @@ fill_mp_bus_to_cpumask(void)
                                for (j = SECONDARY_LDT_BUS_NUMBER(ldtbus);
                                     j <= SUBORDINATE_LDT_BUS_NUMBER(ldtbus);
                                     j++) { 
-                                       int node = NODE_ID(nid);
+                                       struct pci_bus *bus;
+                                       long node = NODE_ID(nid);
+                                       /* Algorithm a bit dumb, but
+                                          it shouldn't matter here */
+                                       bus = pci_find_bus(0, j);
+                                       if (!bus)
+                                               continue;
                                        if (!node_online(node))
                                                node = 0;
-                                       pci_bus_to_node[j] = node;
+                                       bus->sysdata = (void *)node;
                                }               
                        }
                }
diff --git a/include/asm-i386/numa.h b/include/asm-i386/numa.h
new file mode 100644 (file)
index 0000000..96fcb15
--- /dev/null
@@ -0,0 +1,3 @@
+
+int pxm_to_nid(int pxm);
+
index 2461b731781ebc182fd7b70c534b6dd87bb15e76..0ec27c9e8e45ba696be1a06a81df49d27d222729 100644 (file)
@@ -60,7 +60,7 @@ static inline int node_to_first_cpu(int node)
        return first_cpu(mask);
 }
 
-#define pcibus_to_node(bus) mp_bus_id_to_node[(bus)->number]
+#define pcibus_to_node(bus) ((long) (bus)->sysdata)
 #define pcibus_to_cpumask(bus) node_to_cpumask(pcibus_to_node(bus))
 
 /* sched_domains SD_NODE_INIT for NUMAQ machines */
index 3aaf700272133e13f796d9570038ed9fdf05426e..bcf55c3f7f7f35e0f162c504c5f6030578a857f8 100644 (file)
@@ -9,6 +9,7 @@ struct node {
 };
 
 extern int compute_hash_shift(struct node *nodes, int numnodes);
+extern int pxm_to_node(int nid);
 
 #define ZONE_ALIGN (1UL << (MAX_ORDER+PAGE_SHIFT))
 
index c1bc3fad482ed4a4388412ff300a0395f86178a1..1c603cd7e4d096389d7cf92f11b79afcc338b288 100644 (file)
@@ -13,7 +13,6 @@
 extern cpumask_t cpu_online_map;
 
 extern unsigned char cpu_to_node[];
-extern unsigned char pci_bus_to_node[];
 extern cpumask_t     node_to_cpumask[];
 
 #ifdef CONFIG_ACPI_NUMA
@@ -26,7 +25,7 @@ extern int __node_distance(int, int);
 #define parent_node(node)              (node)
 #define node_to_first_cpu(node)        (__ffs(node_to_cpumask[node]))
 #define node_to_cpumask(node)          (node_to_cpumask[node])
-#define pcibus_to_node(bus)            pci_bus_to_node[(bus)->number]
+#define pcibus_to_node(bus)            ((long)(bus->sysdata))  
 #define pcibus_to_cpumask(bus)         node_to_cpumask(pcibus_to_node(bus));
 
 /* sched_domains SD_NODE_INIT for x86_64 machines */