Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / arch / x86_64 / mm / k8topology.c
index ec35747..7c45c2d 100644 (file)
@@ -43,12 +43,14 @@ static __init int find_northbridge(void)
 int __init k8_scan_nodes(unsigned long start, unsigned long end)
 { 
        unsigned long prevbase;
-       struct node nodes[8];
+       struct bootnode nodes[8];
        int nodeid, i, nb; 
+       unsigned char nodeids[8];
        int found = 0;
        u32 reg;
        unsigned numnodes;
        nodemask_t nodes_parsed;
+       unsigned dualcore = 0;
 
        nodes_clear(nodes_parsed);
 
@@ -67,11 +69,15 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
        prevbase = 0;
        for (i = 0; i < 8; i++) { 
                unsigned long base,limit; 
-
+               u32 nodeid;
+               
+               /* Undefined before E stepping, but hopefully 0 */
+               dualcore |= ((read_pci_config(0, nb, 3, 0xe8) >> 12) & 3) == 1;
                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;
                if ((base & 3) == 0) { 
                        if (i < numnodes)
                                printk("Skipping disabled node %d\n", i); 
@@ -102,6 +108,7 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
                limit >>= 16; 
                limit <<= 24; 
                limit |= (1<<24)-1;
+               limit++;
 
                if (limit > end_pfn << PAGE_SHIFT)
                        limit = end_pfn << PAGE_SHIFT;
@@ -148,7 +155,7 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
        if (!found)
                return -1; 
 
-       memnode_shift = compute_hash_shift(nodes, numnodes);
+       memnode_shift = compute_hash_shift(nodes, 8);
        if (memnode_shift < 0) { 
                printk(KERN_ERR "No NUMA node hash function found. Contact maintainer\n"); 
                return -1; 
@@ -157,8 +164,9 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
 
        for (i = 0; i < 8; i++) {
                if (nodes[i].start != nodes[i].end) { 
-                       /* assume 1:1 NODE:CPU */
-                       cpu_to_node[i] = i; 
+                       nodeid = nodeids[i];
+                       apicid_to_node[nodeid << dualcore] = i;
+                       apicid_to_node[(nodeid << dualcore) + dualcore] = i;
                        setup_node_bootmem(i, nodes[i].start, nodes[i].end); 
                } 
        }