diff options
author | Arun KS <arunks.linux@gmail.com> | 2014-05-06 21:41:23 -0400 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2014-05-16 13:03:33 -0400 |
commit | b9acc49ee9464f8f8232a790045d057eb158e869 (patch) | |
tree | e99259f1dfa0e90effebcf3f41da03775bf615ef /arch/arm64 | |
parent | 90f51a09ef83703b6c2e0434e0384b61b59699d3 (diff) |
arm64: Fix deadlock scenario with smp_send_stop()
If one process calls sys_reboot and that process then stops other
CPUs while those CPUs are within a spin_lock() region we can
potentially encounter a deadlock scenario like below.
CPU 0 CPU 1
----- -----
spin_lock(my_lock)
smp_send_stop()
<send IPI> handle_IPI()
disable_preemption/irqs
while(1);
<PREEMPT>
spin_lock(my_lock) <--- Waits forever
We shouldn't attempt to run any other tasks after we send a stop
IPI to a CPU so disable preemption so that this task runs to
completion. We use local_irq_disable() here for cross-arch
consistency with x86.
Based-on-work-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Arun KS <getarunks@gmail.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm64')
-rw-r--r-- | arch/arm64/kernel/process.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index ed37c3694cb8..43b7c34f92cb 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c | |||
@@ -135,6 +135,7 @@ void machine_shutdown(void) | |||
135 | */ | 135 | */ |
136 | void machine_halt(void) | 136 | void machine_halt(void) |
137 | { | 137 | { |
138 | local_irq_disable(); | ||
138 | smp_send_stop(); | 139 | smp_send_stop(); |
139 | while (1); | 140 | while (1); |
140 | } | 141 | } |
@@ -147,6 +148,7 @@ void machine_halt(void) | |||
147 | */ | 148 | */ |
148 | void machine_power_off(void) | 149 | void machine_power_off(void) |
149 | { | 150 | { |
151 | local_irq_disable(); | ||
150 | smp_send_stop(); | 152 | smp_send_stop(); |
151 | if (pm_power_off) | 153 | if (pm_power_off) |
152 | pm_power_off(); | 154 | pm_power_off(); |
@@ -165,10 +167,9 @@ void machine_power_off(void) | |||
165 | */ | 167 | */ |
166 | void machine_restart(char *cmd) | 168 | void machine_restart(char *cmd) |
167 | { | 169 | { |
168 | smp_send_stop(); | ||
169 | |||
170 | /* Disable interrupts first */ | 170 | /* Disable interrupts first */ |
171 | local_irq_disable(); | 171 | local_irq_disable(); |
172 | smp_send_stop(); | ||
172 | 173 | ||
173 | /* Now call the architecture specific reboot code. */ | 174 | /* Now call the architecture specific reboot code. */ |
174 | if (arm_pm_restart) | 175 | if (arm_pm_restart) |