From e91e991e13b07f0666cb0eea1d00da65c478f9cf Mon Sep 17 00:00:00 2001 From: "Mike J. Chen" Date: Thu, 24 May 2012 15:12:36 -0700 Subject: [PATCH] ARM: disable preemption in machine_shutdown Since the smp call to stop the other cpus are handled in those cpus in interrupt context, there's a potential for those smp handlers to interrupt threads holding spin locks (such as the one a mutex holds). This prevents those threads from ever releasing their spin lock, so if the cpu doing the shutdown is allowed to switch to another thread that tries to grab the same lock/mutex, we could get into a deadlock (the spin lock call is called with preemption disabled in the mutex lock code). To avoid that possibility, disable preemption before doing the smp_send_stop(). Change-Id: I7976c5382d7173fcb3cd14da8cc5083d442b2544 Signed-off-by: Mike J. Chen --- arch/arm/kernel/process.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c index 09f001a10946..d12f92e011d4 100644 --- a/arch/arm/kernel/process.c +++ b/arch/arm/kernel/process.c @@ -235,6 +235,16 @@ __setup("reboot=", reboot_setup); */ void machine_shutdown(void) { +#ifdef CONFIG_SMP + /* + * Disable preemption so we're guaranteed to + * run to power off or reboot and prevent + * the possibility of switching to another + * thread that might wind up blocking on + * one of the stopped CPUs. + */ + preempt_disable(); +#endif disable_nonboot_cpus(); } -- 2.34.1