[POWERPC] Rename get_property to of_get_property: arch/powerpc
[powerpc.git] / arch / powerpc / mm / numa.c
index 9da01dc..b3a592b 100644 (file)
@@ -74,7 +74,7 @@ static struct device_node * __cpuinit find_cpu_node(unsigned int cpu)
 
        while ((cpu_node = of_find_node_by_type(cpu_node, "cpu")) != NULL) {
                /* Try interrupt server first */
-               interrupt_server = get_property(cpu_node,
+               interrupt_server = of_get_property(cpu_node,
                                        "ibm,ppc-interrupt-server#s", &len);
 
                len = len / sizeof(u32);
@@ -85,7 +85,7 @@ static struct device_node * __cpuinit find_cpu_node(unsigned int cpu)
                                        return cpu_node;
                        }
                } else {
-                       reg = get_property(cpu_node, "reg", &len);
+                       reg = of_get_property(cpu_node, "reg", &len);
                        if (reg && (len > 0) && (reg[0] == hw_cpuid))
                                return cpu_node;
                }
@@ -97,7 +97,7 @@ static struct device_node * __cpuinit find_cpu_node(unsigned int cpu)
 /* must hold reference to node during call */
 static const int *of_get_associativity(struct device_node *dev)
 {
-       return get_property(dev, "ibm,associativity", NULL);
+       return of_get_property(dev, "ibm,associativity", NULL);
 }
 
 /* Returns nid in the range [0..MAX_NUMNODES-1], or -1 if no useful numa
@@ -154,7 +154,7 @@ EXPORT_SYMBOL_GPL(of_node_to_nid);
  * characteristics relative to its multiple connections.  We ignore
  * this for now.  We also assume that all cpu and memory sets have
  * their distances represented at a common level.  This won't be
- * true for heirarchical NUMA.
+ * true for hierarchical NUMA.
  *
  * In any case the ibm,associativity-reference-points should give
  * the correct depth for a normal NUMA system.
@@ -179,7 +179,7 @@ static int __init find_min_common_depth(void)
         * configuration (should be all 0's) and the second is for a normal
         * NUMA configuration.
         */
-       ref_points = get_property(rtas_root,
+       ref_points = of_get_property(rtas_root,
                        "ibm,associativity-reference-points", &len);
 
        if ((len >= 1) && ref_points) {
@@ -201,8 +201,8 @@ static void __init get_n_mem_cells(int *n_addr_cells, int *n_size_cells)
        if (!memory)
                panic("numa.c: No memory nodes found!");
 
-       *n_addr_cells = prom_n_addr_cells(memory);
-       *n_size_cells = prom_n_size_cells(memory);
+       *n_addr_cells = of_n_addr_cells(memory);
+       *n_size_cells = of_n_size_cells(memory);
        of_node_put(memory);
 }
 
@@ -295,6 +295,63 @@ static unsigned long __init numa_enforce_memory_limit(unsigned long start,
        return lmb_end_of_DRAM() - start;
 }
 
+/*
+ * Extract NUMA information from the ibm,dynamic-reconfiguration-memory
+ * node.  This assumes n_mem_{addr,size}_cells have been set.
+ */
+static void __init parse_drconf_memory(struct device_node *memory)
+{
+       const unsigned int *lm, *dm, *aa;
+       unsigned int ls, ld, la;
+       unsigned int n, aam, aalen;
+       unsigned long lmb_size, size;
+       int nid, default_nid = 0;
+       unsigned int start, ai, flags;
+
+       lm = of_get_property(memory, "ibm,lmb-size", &ls);
+       dm = of_get_property(memory, "ibm,dynamic-memory", &ld);
+       aa = of_get_property(memory, "ibm,associativity-lookup-arrays", &la);
+       if (!lm || !dm || !aa ||
+           ls < sizeof(unsigned int) || ld < sizeof(unsigned int) ||
+           la < 2 * sizeof(unsigned int))
+               return;
+
+       lmb_size = read_n_cells(n_mem_size_cells, &lm);
+       n = *dm++;              /* number of LMBs */
+       aam = *aa++;            /* number of associativity lists */
+       aalen = *aa++;          /* length of each associativity list */
+       if (ld < (n * (n_mem_addr_cells + 4) + 1) * sizeof(unsigned int) ||
+           la < (aam * aalen + 2) * sizeof(unsigned int))
+               return;
+
+       for (; n != 0; --n) {
+               start = read_n_cells(n_mem_addr_cells, &dm);
+               ai = dm[2];
+               flags = dm[3];
+               dm += 4;
+               /* 0x80 == reserved, 0x8 = assigned to us */
+               if ((flags & 0x80) || !(flags & 0x8))
+                       continue;
+               nid = default_nid;
+               /* flags & 0x40 means associativity index is invalid */
+               if (min_common_depth > 0 && min_common_depth <= aalen &&
+                   (flags & 0x40) == 0 && ai < aam) {
+                       /* this is like of_node_to_nid_single */
+                       nid = aa[ai * aalen + min_common_depth - 1];
+                       if (nid == 0xffff || nid >= MAX_NUMNODES)
+                               nid = default_nid;
+               }
+               node_set_online(nid);
+
+               size = numa_enforce_memory_limit(start, lmb_size);
+               if (!size)
+                       continue;
+
+               add_active_range(nid, start >> PAGE_SHIFT,
+                                (start >> PAGE_SHIFT) + (size >> PAGE_SHIFT));
+       }
+}
+
 static int __init parse_numa_properties(void)
 {
        struct device_node *cpu = NULL;
@@ -347,10 +404,10 @@ static int __init parse_numa_properties(void)
                const unsigned int *memcell_buf;
                unsigned int len;
 
-               memcell_buf = get_property(memory,
+               memcell_buf = of_get_property(memory,
                        "linux,usable-memory", &len);
                if (!memcell_buf || len <= 0)
-                       memcell_buf = get_property(memory, "reg", &len);
+                       memcell_buf = of_get_property(memory, "reg", &len);
                if (!memcell_buf || len <= 0)
                        continue;
 
@@ -385,6 +442,14 @@ new_range:
                        goto new_range;
        }
 
+       /*
+        * Now do the same thing for each LMB listed in the ibm,dynamic-memory
+        * property in the ibm,dynamic-reconfiguration-memory node.
+        */
+       memory = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
+       if (memory)
+               parse_drconf_memory(memory);
+
        return 0;
 }
 
@@ -660,7 +725,7 @@ int hot_add_scn_to_nid(unsigned long scn_addr)
                const unsigned int *memcell_buf;
                unsigned int len;
 
-               memcell_buf = get_property(memory, "reg", &len);
+               memcell_buf = of_get_property(memory, "reg", &len);
                if (!memcell_buf || len <= 0)
                        continue;