]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
ARM: SMP: move CPU number sanity checks to smp_init_cpus()
authorRussell King <rmk+kernel@arm.linux.org.uk>
Fri, 3 Dec 2010 10:42:58 +0000 (10:42 +0000)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Mon, 20 Dec 2010 15:08:26 +0000 (15:08 +0000)
Ensure that the number of CPUs is sanity checked before setting
the number of possible CPUs.  This avoids any chance of overflowing
the cpu_possible bitmap.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mach-omap2/omap-smp.c
arch/arm/mach-realview/platsmp.c
arch/arm/mach-ux500/platsmp.c

index 56a8bce247c89a8c39604e866dc8d1235dcbd1a0..3c87468ce9cbb59dfa5cb06f20d4960c9a3c57e8 100644 (file)
@@ -120,16 +120,6 @@ void __init smp_init_cpus(void)
 
        ncores = get_core_count();
 
-       for (i = 0; i < ncores; i++)
-               set_cpu_possible(i, true);
-}
-
-void __init smp_prepare_cpus(unsigned int max_cpus)
-{
-       unsigned int ncores = get_core_count();
-       unsigned int cpu = smp_processor_id();
-       int i;
-
        /* sanity check */
        if (ncores == 0) {
                printk(KERN_ERR
@@ -144,6 +134,17 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
                       ncores, NR_CPUS);
                ncores = NR_CPUS;
        }
+
+       for (i = 0; i < ncores; i++)
+               set_cpu_possible(i, true);
+}
+
+void __init smp_prepare_cpus(unsigned int max_cpus)
+{
+       unsigned int ncores = num_possible_cpus();
+       unsigned int cpu = smp_processor_id();
+       int i;
+
        smp_store_cpu_info(cpu);
 
        /*
index af3d9093390b6db6e3fc63003d35dcf55760a0fa..108e92f9746b095ae16fcaea14f118bb8fa82a39 100644 (file)
@@ -160,16 +160,6 @@ void __init smp_init_cpus(void)
 {
        unsigned int i, ncores = get_core_count();
 
-       for (i = 0; i < ncores; i++)
-               set_cpu_possible(i, true);
-}
-
-void __init smp_prepare_cpus(unsigned int max_cpus)
-{
-       unsigned int ncores = get_core_count();
-       unsigned int cpu = smp_processor_id();
-       int i;
-
        /* sanity check */
        if (ncores == 0) {
                printk(KERN_ERR
@@ -186,6 +176,16 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
                ncores = NR_CPUS;
        }
 
+       for (i = 0; i < ncores; i++)
+               set_cpu_possible(i, true);
+}
+
+void __init smp_prepare_cpus(unsigned int max_cpus)
+{
+       unsigned int ncores = num_possible_cpus();
+       unsigned int cpu = smp_processor_id();
+       int i;
+
        smp_store_cpu_info(cpu);
 
        /*
index b8987bd212497828a9b601410683e62826a4d38d..a51962b7579baa1a8f589c95524f89e7f62d8f8e 100644 (file)
@@ -128,16 +128,6 @@ void __init smp_init_cpus(void)
 {
        unsigned int i, ncores = get_core_count();
 
-       for (i = 0; i < ncores; i++)
-               set_cpu_possible(i, true);
-}
-
-void __init smp_prepare_cpus(unsigned int max_cpus)
-{
-       unsigned int ncores = get_core_count();
-       unsigned int cpu = smp_processor_id();
-       int i;
-
        /* sanity check */
        if (ncores == 0) {
                printk(KERN_ERR
@@ -145,14 +135,24 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
                ncores = 1;
        }
 
-       if (ncores > num_possible_cpus())       {
+       if (ncores > NR_CPUS) {
                printk(KERN_WARNING
                       "U8500: no. of cores (%d) greater than configured "
                       "maximum of %d - clipping\n",
-                      ncores, num_possible_cpus());
-               ncores = num_possible_cpus();
+                      ncores, NR_CPUS);
+               ncores = NR_CPUS;
        }
 
+       for (i = 0; i < ncores; i++)
+               set_cpu_possible(i, true);
+}
+
+void __init smp_prepare_cpus(unsigned int max_cpus)
+{
+       unsigned int ncores = num_possible_cpus();
+       unsigned int cpu = smp_processor_id();
+       int i;
+
        smp_store_cpu_info(cpu);
 
        /*