linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / arch / mips / sgi-ip27 / ip27-memory.c
index 327eadb..ef20d9a 100644 (file)
@@ -3,18 +3,20 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 2000 by Ralf Baechle
+ * Copyright (C) 2000, 05 by Ralf Baechle (ralf@linux-mips.org)
  * Copyright (C) 2000 by Silicon Graphics, Inc.
  * Copyright (C) 2004 by Christoph Hellwig
  *
  * On SGI IP27 the ARC memory configuration data is completly bogus but
  * alternate easier to use mechanisms are available.
  */
+#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/mmzone.h>
 #include <linux/module.h>
+#include <linux/nodemask.h>
 #include <linux/swap.h>
 #include <linux/bootmem.h>
 #include <asm/page.h>
@@ -59,12 +61,12 @@ static hubreg_t get_region(cnodeid_t cnode)
 
 static hubreg_t region_mask;
 
-static void gen_region_mask(hubreg_t *region_mask, int maxnodes)
+static void gen_region_mask(hubreg_t *region_mask)
 {
        cnodeid_t cnode;
 
        (*region_mask) = 0;
-       for (cnode = 0; cnode < maxnodes; cnode++) {
+       for_each_online_node(cnode) {
                (*region_mask) |= 1ULL << get_region(cnode);
        }
 }
@@ -120,7 +122,7 @@ static int __init compute_node_distance(nasid_t nasid_a, nasid_t nasid_b)
        int port;
 
        /* Figure out which routers nodes in question are connected to */
-       for (cnode = 0; cnode < numnodes; cnode++) {
+       for_each_online_node(cnode) {
                nasid = COMPACT_TO_NASID_NODEID(cnode);
 
                if (nasid == -1) continue;
@@ -187,9 +189,9 @@ static void __init init_topology_matrix(void)
                for (col = 0; col < MAX_COMPACT_NODES; col++)
                        __node_distances[row][col] = -1;
 
-       for (row = 0; row < numnodes; row++) {
+       for_each_online_node(row) {
                nasid = COMPACT_TO_NASID_NODEID(row);
-               for (col = 0; col < numnodes; col++) {
+               for_each_online_node(col) {
                        nasid2 = COMPACT_TO_NASID_NODEID(col);
                        __node_distances[row][col] =
                                compute_node_distance(nasid, nasid2);
@@ -210,17 +212,17 @@ static void __init dump_topology(void)
        printk("************** Topology ********************\n");
 
        printk("    ");
-       for (col = 0; col < numnodes; col++)
+       for_each_online_node(col)
                printk("%02d ", col);
        printk("\n");
-       for (row = 0; row < numnodes; row++) {
+       for_each_online_node(row) {
                printk("%02d  ", row);
-               for (col = 0; col < numnodes; col++)
+               for_each_online_node(col)
                        printk("%2d ", node_distance(row, col));
                printk("\n");
        }
 
-       for (cnode = 0; cnode < numnodes; cnode++) {
+       for_each_online_node(cnode) {
                nasid = COMPACT_TO_NASID_NODEID(cnode);
 
                if (nasid == -1) continue;
@@ -363,14 +365,14 @@ static void __init mlreset(void)
        init_topology_matrix();
        dump_topology();
 
-       gen_region_mask(&region_mask, numnodes);
+       gen_region_mask(&region_mask);
 
-       setup_replication_mask(numnodes);
+       setup_replication_mask();
 
        /*
         * Set all nodes' calias sizes to 8k
         */
-       for (i = 0; i < numnodes; i++) {
+       for_each_online_node(i) {
                nasid_t nasid;
 
                nasid = COMPACT_TO_NASID_NODEID(i);
@@ -407,7 +409,7 @@ static void __init szmem(void)
 
        num_physpages = 0;
 
-       for (node = 0; node < numnodes; node++) {
+       for_each_online_node(node) {
                ignore = nodebytes = 0;
                for (slot = 0; slot < MAX_MEM_SLOTS; slot++) {
                        slot_psize = slot_psize_compute(node, slot);
@@ -489,7 +491,7 @@ void __init prom_meminit(void)
        szmem();
 
        for (node = 0; node < MAX_COMPACT_NODES; node++) {
-               if (node < numnodes) {
+               if (node_online(node)) {
                        node_mem_init(node);
                        continue;
                }
@@ -513,7 +515,7 @@ void __init paging_init(void)
 
        pagetable_init();
 
-       for (node = 0; node < numnodes; node++) {
+       for_each_online_node(node) {
                pfn_t start_pfn = slot_getbasepfn(node, 0);
                pfn_t end_pfn = node_getmaxclick(node) + 1;
 
@@ -533,10 +535,10 @@ void __init mem_init(void)
 
        high_memory = (void *) __va(num_physpages << PAGE_SHIFT);
 
-       for (node = 0; node < numnodes; node++) {
+       for_each_online_node(node) {
                unsigned slot, numslots;
                struct page *end, *p;
-       
+
                /*
                 * This will free up the bootmem, ie, slot 0 memory.
                 */
@@ -547,9 +549,8 @@ void __init mem_init(void)
                 */
                numslots = node_getlastslot(node);
                for (slot = 1; slot <= numslots; slot++) {
-                       p = NODE_DATA(node)->node_mem_map +
-                               (slot_getbasepfn(node, slot) -
-                                slot_getbasepfn(node, 0));
+                       p = nid_page_nr(node, slot_getbasepfn(node, slot) -
+                                             slot_getbasepfn(node, 0));
 
                        /*
                         * Free valid memory in current slot.