]> xenbits.xensource.com Git - people/liuw/freebsd.git/commitdiff
Since r289279 bufinit() uses mp_ncpus, but some architectures set this
authortijl <tijl@FreeBSD.org>
Sun, 8 Nov 2015 14:26:50 +0000 (14:26 +0000)
committertijl <tijl@FreeBSD.org>
Sun, 8 Nov 2015 14:26:50 +0000 (14:26 +0000)
variable during mp_start() which is too late.  Move this to mp_setmaxid()
where other architectures set it and move x86 assertions to MI code.

Reviewed by: kib (x86 part)

sys/arm/annapurna/alpine/alpine_machdep_mp.c
sys/arm/mv/armadaxp/armadaxp_mp.c
sys/arm/qemu/virt_mp.c
sys/arm/ti/omap4/omap4_mp.c
sys/arm/xilinx/zy7_mp.c
sys/kern/subr_smp.c
sys/x86/x86/mp_x86.c

index a4c45b8d07fb49fc53a307faa66f31415d4eaf04..4420025c7d7002f165a754d6e53e84b2e7c55679 100644 (file)
@@ -128,16 +128,14 @@ platform_mp_init_secondary(void)
 void
 platform_mp_setmaxid(void)
 {
-       int core_cnt;
 
-       core_cnt = platform_mp_get_core_cnt();
-       mp_maxid = core_cnt - 1;
+       mp_ncpus = platform_mp_get_core_cnt();
+       mp_maxid = mp_ncpus - 1;
 }
 
 int
 platform_mp_probe(void)
 {
-       mp_ncpus = platform_mp_get_core_cnt();
        return (1);
 }
 
index 1fa4d5311738b7b0ecc2e1028dd6c5c19b8e156a..6685204b59eded7e5e6ae6a68410fe0b536e0049 100644 (file)
@@ -82,15 +82,14 @@ void
 platform_mp_setmaxid(void)
 {
 
-       mp_maxid = 3;
+       mp_ncpus = platform_get_ncpus();
+       mp_maxid = mp_ncpus - 1;
 }
 
 int
 platform_mp_probe(void)
 {
 
-       mp_ncpus = platform_get_ncpus();
-
        return (mp_ncpus > 1);
 }
 
index 2fe1592af0fd25e0b4f0eecd57e0656cb87ce9c0..89a30c631f9d0ff9a56b33edb71706dd41d44c61 100644 (file)
@@ -49,17 +49,8 @@ static int running_cpus;
 int
 platform_mp_probe(void)
 {
-       int ncpus;
 
-       ncpus = ofw_cpu_early_foreach(NULL, true);
-       if (ncpus <= 1) {
-               mp_ncpus = 1;
-               return (0);
-       }
-
-       mp_ncpus = MIN(ncpus, MAXCPU);
-
-       return (1);
+       return (mp_ncpus > 1);
 }
 
 static boolean_t
@@ -77,7 +68,10 @@ platform_mp_setmaxid(void)
 {
 
        mp_maxid = PCPU_GET(cpuid);
-       ofw_cpu_early_foreach(virt_maxid, true);
+       mp_ncpus = ofw_cpu_early_foreach(virt_maxid, true);
+       if (mp_ncpus < 1)
+               mp_ncpus = 1;
+       mp_ncpus = MIN(ncpus, MAXCPU);
 }
 
 static boolean_t
index f53748e90a9aa621a12cb468b62f9cf04b74b98f..c32d302016963928ef298283e8c137399f573415 100644 (file)
@@ -51,14 +51,14 @@ void
 platform_mp_setmaxid(void)
 {
 
-        mp_maxid = 1;
+       mp_maxid = 1;
+       mp_ncpus = 2;
 }
 
 int
 platform_mp_probe(void)
 {
 
-       mp_ncpus = 2;
        return (1);
 }
 
index 24e8595a5af39192efb643920544e8088e572ace..c87cf29b4eaea87f76bc6e4ef353b7c2c088fd98 100644 (file)
@@ -57,13 +57,13 @@ platform_mp_setmaxid(void)
 {
 
        mp_maxid = 1;
+       mp_ncpus = 2;
 }
 
 int
 platform_mp_probe(void)
 {
 
-       mp_ncpus = 2;
        return (1);
 }
 
index 0ac3b17aa148c3995eb0d51ae3bad77942bafd63..82349f87fdd1d12841a92b65a3e08e836445be12 100644 (file)
@@ -125,7 +125,15 @@ struct mtx smp_ipi_mtx;
 static void
 mp_setmaxid(void *dummy)
 {
+
        cpu_mp_setmaxid();
+
+       KASSERT(mp_ncpus >= 1, ("%s: CPU count < 1", __func__));
+       KASSERT(mp_ncpus > 1 || mp_maxid == 0,
+           ("%s: one CPU but mp_maxid is not zero", __func__));
+       KASSERT(mp_maxid >= mp_ncpus - 1,
+           ("%s: counters out of sync: max %d, count %d", __func__,
+               mp_maxid, mp_ncpus));
 }
 SYSINIT(cpu_mp_setmaxid, SI_SUB_TUNABLES, SI_ORDER_FIRST, mp_setmaxid, NULL);
 
index 9e1cec241d519d1d2eddcde39e20f15dea737256..a9f3f1b2435042cfa977ee85198501229dbad91b 100644 (file)
@@ -425,18 +425,11 @@ cpu_mp_setmaxid(void)
 {
 
        /*
-        * mp_maxid should be already set by calls to cpu_add().
-        * Just sanity check its value here.
+        * mp_ncpus and mp_maxid should be already set by calls to cpu_add().
+        * If there were no calls to cpu_add() assume this is a UP system.
         */
        if (mp_ncpus == 0)
-               KASSERT(mp_maxid == 0,
-                   ("%s: mp_ncpus is zero, but mp_maxid is not", __func__));
-       else if (mp_ncpus == 1)
-               mp_maxid = 0;
-       else
-               KASSERT(mp_maxid >= mp_ncpus - 1,
-                   ("%s: counters out of sync: max %d, count %d", __func__,
-                       mp_maxid, mp_ncpus));
+               mp_ncpus = 1;
 }
 
 int
@@ -448,28 +441,7 @@ cpu_mp_probe(void)
         * correctly.
         */
        CPU_SETOF(0, &all_cpus);
-       if (mp_ncpus == 0) {
-               /*
-                * No CPUs were found, so this must be a UP system.  Setup
-                * the variables to represent a system with a single CPU
-                * with an id of 0.
-                */
-               mp_ncpus = 1;
-               return (0);
-       }
-
-       /* At least one CPU was found. */
-       if (mp_ncpus == 1) {
-               /*
-                * One CPU was found, so this must be a UP system with
-                * an I/O APIC.
-                */
-               mp_maxid = 0;
-               return (0);
-       }
-
-       /* At least two CPUs were found. */
-       return (1);
+       return (mp_ncpus > 1);
 }
 
 /*