Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e5105fc8 authored by Mike J. Chen's avatar Mike J. Chen Committed by Ruchi Kandoi
Browse files

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: default avatarMike J. Chen <mjchen@google.com>
parent 04a64c1b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -217,6 +217,16 @@ void arch_cpu_idle_dead(void)
 */
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();
}