[SERIAL] 8250: sysrq deadlock fix

Fix http://bugzilla.kernel.org/show_bug.cgi?id=6716

Doing a sysrq over a serial line into an SMP machine presently deadlocks.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by Andrew Morton and committed by Russell King 68aa2c0d 3be91ec7

+9 -4
+9 -4
drivers/serial/8250.c
··· 2252 2253 touch_nmi_watchdog(); 2254 2255 - if (oops_in_progress) { 2256 - locked = spin_trylock_irqsave(&up->port.lock, flags); 2257 } else 2258 - spin_lock_irqsave(&up->port.lock, flags); 2259 2260 /* 2261 * First save the IER then disable the interrupts ··· 2281 serial_out(up, UART_IER, ier); 2282 2283 if (locked) 2284 - spin_unlock_irqrestore(&up->port.lock, flags); 2285 } 2286 2287 static int serial8250_console_setup(struct console *co, char *options)
··· 2252 2253 touch_nmi_watchdog(); 2254 2255 + local_irq_save(flags); 2256 + if (up->port.sysrq) { 2257 + /* serial8250_handle_port() already took the lock */ 2258 + locked = 0; 2259 + } else if (oops_in_progress) { 2260 + locked = spin_trylock(&up->port.lock); 2261 } else 2262 + spin_lock(&up->port.lock); 2263 2264 /* 2265 * First save the IER then disable the interrupts ··· 2277 serial_out(up, UART_IER, ier); 2278 2279 if (locked) 2280 + spin_unlock(&up->port.lock); 2281 + local_irq_restore(flags); 2282 } 2283 2284 static int serial8250_console_setup(struct console *co, char *options)