]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - arch/powerpc/mm/numa.c
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/scottwood/linux.git
[karo-tx-linux.git] / arch / powerpc / mm / numa.c
index 5eb07f332de1d0fe46fd30bf22f06ba7eb9cb615..649666d5d1c20520ed554a3375c11393660871e1 100644 (file)
@@ -538,7 +538,7 @@ static int of_drconf_to_nid_single(struct of_drconf_cell *drmem,
  */
 static int numa_setup_cpu(unsigned long lcpu)
 {
-       int nid;
+       int nid = -1;
        struct device_node *cpu;
 
        /*
@@ -555,19 +555,21 @@ static int numa_setup_cpu(unsigned long lcpu)
 
        if (!cpu) {
                WARN_ON(1);
-               nid = 0;
-               goto out;
+               if (cpu_present(lcpu))
+                       goto out_present;
+               else
+                       goto out;
        }
 
        nid = of_node_to_nid_single(cpu);
 
+out_present:
        if (nid < 0 || !node_online(nid))
                nid = first_online_node;
-out:
-       map_cpu_to_node(lcpu, nid);
 
+       map_cpu_to_node(lcpu, nid);
        of_node_put(cpu);
-
+out:
        return nid;
 }
 
@@ -611,8 +613,8 @@ static int cpu_numa_callback(struct notifier_block *nfb, unsigned long action,
        case CPU_UP_CANCELED:
        case CPU_UP_CANCELED_FROZEN:
                unmap_cpu_from_node(lcpu);
-               break;
                ret = NOTIFY_OK;
+               break;
 #endif
        }
        return ret;
@@ -1049,7 +1051,7 @@ static void __init mark_reserved_regions_for_nid(int nid)
 
 void __init do_init_bootmem(void)
 {
-       int nid;
+       int nid, cpu;
 
        min_low_pfn = 0;
        max_low_pfn = memblock_end_of_DRAM() >> PAGE_SHIFT;
@@ -1122,8 +1124,14 @@ void __init do_init_bootmem(void)
 
        reset_numa_cpu_lookup_table();
        register_cpu_notifier(&ppc64_numa_nb);
-       cpu_numa_callback(&ppc64_numa_nb, CPU_UP_PREPARE,
-                         (void *)(unsigned long)boot_cpuid);
+       /*
+        * We need the numa_cpu_lookup_table to be accurate for all CPUs,
+        * even before we online them, so that we can use cpu_to_{node,mem}
+        * early in boot, cf. smp_prepare_cpus().
+        */
+       for_each_present_cpu(cpu) {
+               numa_setup_cpu((unsigned long)cpu);
+       }
 }
 
 static int __init early_numa(char *p)