]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - arch/powerpc/mm/numa.c
powerpc/mm/drconf: Use NUMA_NO_NODE on failures instead of node 0
[linux.git] / arch / powerpc / mm / numa.c
index 57e64273cb33b31899cd43608627fa715ccd5a56..b1ecfb850b5a9978a43bb63cb19df99de09a7e75 100644 (file)
@@ -167,6 +167,22 @@ static void unmap_cpu_from_node(unsigned long cpu)
 }
 #endif /* CONFIG_HOTPLUG_CPU || CONFIG_PPC_SPLPAR */
 
+int cpu_distance(__be32 *cpu1_assoc, __be32 *cpu2_assoc)
+{
+       int dist = 0;
+
+       int i, index;
+
+       for (i = 0; i < distance_ref_points_depth; i++) {
+               index = be32_to_cpu(distance_ref_points[i]);
+               if (cpu1_assoc[index] == cpu2_assoc[index])
+                       break;
+               dist++;
+       }
+
+       return dist;
+}
+
 /* must hold reference to node during call */
 static const __be32 *of_get_associativity(struct device_node *dev)
 {
@@ -420,17 +436,19 @@ static int of_get_assoc_arrays(struct assoc_arrays *aa)
 static int of_drconf_to_nid_single(struct drmem_lmb *lmb)
 {
        struct assoc_arrays aa = { .arrays = NULL };
-       int default_nid = 0;
+       int default_nid = NUMA_NO_NODE;
        int nid = default_nid;
        int rc, index;
 
+       if (min_common_depth < 0)
+               return default_nid;
+
        rc = of_get_assoc_arrays(&aa);
        if (rc)
                return default_nid;
 
-       if (min_common_depth > 0 && min_common_depth <= aa.array_sz &&
-           !(lmb->flags & DRCONF_MEM_AI_INVALID) &&
-           lmb->aa_index < aa.n_arrays) {
+       if (min_common_depth <= aa.array_sz &&
+           !(lmb->flags & DRCONF_MEM_AI_INVALID) && lmb->aa_index < aa.n_arrays) {
                index = lmb->aa_index * aa.array_sz + min_common_depth - 1;
                nid = of_read_number(&aa.arrays[index], 1);
 
@@ -1067,9 +1085,6 @@ u64 memory_hotplug_max(void)
 
 /* Virtual Processor Home Node (VPHN) support */
 #ifdef CONFIG_PPC_SPLPAR
-
-#include "book3s64/vphn.h"
-
 struct topology_update_data {
        struct topology_update_data *next;
        unsigned int cpu;
@@ -1165,25 +1180,13 @@ static int update_cpu_associativity_changes_mask(void)
  * Retrieve the new associativity information for a virtual processor's
  * home node.
  */
-static long hcall_vphn(unsigned long cpu, __be32 *associativity)
-{
-       long rc;
-       long retbuf[PLPAR_HCALL9_BUFSIZE] = {0};
-       u64 flags = 1;
-       int hwcpu = get_hard_smp_processor_id(cpu);
-
-       rc = plpar_hcall9(H_HOME_NODE_ASSOCIATIVITY, retbuf, flags, hwcpu);
-       vphn_unpack_associativity(retbuf, associativity);
-
-       return rc;
-}
-
 static long vphn_get_associativity(unsigned long cpu,
                                        __be32 *associativity)
 {
        long rc;
 
-       rc = hcall_vphn(cpu, associativity);
+       rc = hcall_vphn(get_hard_smp_processor_id(cpu),
+                               VPHN_FLAG_VCPU, associativity);
 
        switch (rc) {
        case H_FUNCTION: