ARM: SMP: ensure smp_send_stop() waits for CPUs to stop
authorDonghan Ryu <dryu@nvidia.com>
Mon, 11 Apr 2011 03:14:55 +0000 (12:14 +0900)
committerVarun Colbert <vcolbert@nvidia.com>
Fri, 15 Apr 2011 04:28:55 +0000 (21:28 -0700)
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.

Bug 810939

(cherry picked from commit 28e18293cf0f8d23a0950d7b1d2212d11af494dc)

Change-Id: I87fbaad50a50789dc9a12b1f27d51372ffd6aaf1
Reviewed-on: http://git-master/r/27828
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>
arch/arm/kernel/smp.c

index 7c5ddb11189758c3c18b1e7fafd2b7d5e6a2c3f0..2a3288701baed30a590dec0dda35e5dfed900f67 100644 (file)
@@ -518,9 +518,22 @@ void smp_send_reschedule(int cpu)
 
 void smp_send_stop(void)
 {
-       cpumask_t mask = cpu_online_map;
-       cpu_clear(smp_processor_id(), mask);
-       send_ipi_message(&mask, IPI_CPU_STOP);
+       unsigned long timeout;
+
+       if (num_online_cpus() > 1) {
+               cpumask_t mask = cpu_online_map;
+               cpu_clear(smp_processor_id(), mask);
+
+               send_ipi_message(&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 ");
 }
 
 /*