]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
ARM: SMP: ensure smp_send_stop() waits for CPUs to stop
authorRussell King <rmk+kernel@arm.linux.org.uk>
Thu, 2 Dec 2010 09:53:54 +0000 (09:53 +0000)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Mon, 20 Dec 2010 15:08:26 +0000 (15:08 +0000)
Wait for CPUs to indicate that they've stopped, after sending the
stop IPI, rather than blindly continuing on and hoping that they've
stopped in time.  Print a warning if we fail to stop the other CPUs.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/kernel/smp.c

index 1de3e13a42a116d8188575234237b6843f0fcb10..64f2d198c7647bc455c55fe641f95269d7e9911f 100644 (file)
@@ -575,10 +575,22 @@ void smp_send_reschedule(int cpu)
 
 void smp_send_stop(void)
 {
-       cpumask_t mask = cpu_online_map;
-       cpu_clear(smp_processor_id(), mask);
-       if (!cpus_empty(mask))
+       unsigned long timeout;
+
+       if (num_online_cpus() > 1) {
+               cpumask_t mask = cpu_online_map;
+               cpu_clear(smp_processor_id(), mask);
+
                smp_cross_call(&mask, IPI_CPU_STOP);
+       }
+
+       /* Wait up to one second for other CPUs to stop */
+       timeout = USEC_PER_SEC;
+       while (num_online_cpus() > 1 && timeout--)
+               udelay(1);
+
+       if (num_online_cpus() > 1)
+               pr_warning("SMP: failed to stop secondary CPUs\n");
 }
 
 /*