serial: 8250: Process sysrq at port unlock time

Let's take advantage of the new ("serial: core: Allow processing sysrq
at port unlock time") to handle sysrqs more cleanly.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Douglas Anderson 2018-10-30 15:11:07 -07:00 committed by Greg Kroah-Hartman
parent 3e6f880683
commit 596f63da42
4 changed files with 18 additions and 8 deletions

View File

@ -5,6 +5,10 @@
* Copyright (C) 2016 Jeremy Kerr <jk@ozlabs.org>, IBM Corp. * Copyright (C) 2016 Jeremy Kerr <jk@ozlabs.org>, IBM Corp.
* Copyright (C) 2006 Arnd Bergmann <arnd@arndb.de>, IBM Corp. * Copyright (C) 2006 Arnd Bergmann <arnd@arndb.de>, IBM Corp.
*/ */
#if defined(CONFIG_SERIAL_8250_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
#define SUPPORT_SYSRQ
#endif
#include <linux/device.h> #include <linux/device.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of_address.h> #include <linux/of_address.h>
@ -293,7 +297,7 @@ static int aspeed_vuart_handle_irq(struct uart_port *port)
if (lsr & UART_LSR_THRE) if (lsr & UART_LSR_THRE)
serial8250_tx_chars(up); serial8250_tx_chars(up);
spin_unlock_irqrestore(&port->lock, flags); uart_unlock_and_check_sysrq(port, flags);
return 1; return 1;
} }

View File

@ -1,4 +1,8 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#if defined(CONFIG_SERIAL_8250_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
#define SUPPORT_SYSRQ
#endif
#include <linux/serial_reg.h> #include <linux/serial_reg.h>
#include <linux/serial_8250.h> #include <linux/serial_8250.h>
@ -54,7 +58,7 @@ int fsl8250_handle_irq(struct uart_port *port)
serial8250_tx_chars(up); serial8250_tx_chars(up);
up->lsr_saved_flags = orig_lsr; up->lsr_saved_flags = orig_lsr;
spin_unlock_irqrestore(&up->port.lock, flags); uart_unlock_and_check_sysrq(&up->port, flags);
return 1; return 1;
} }
EXPORT_SYMBOL_GPL(fsl8250_handle_irq); EXPORT_SYMBOL_GPL(fsl8250_handle_irq);

View File

@ -8,6 +8,10 @@
* *
*/ */
#if defined(CONFIG_SERIAL_8250_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
#define SUPPORT_SYSRQ
#endif
#include <linux/device.h> #include <linux/device.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/module.h> #include <linux/module.h>
@ -1085,7 +1089,7 @@ static int omap_8250_dma_handle_irq(struct uart_port *port)
} }
} }
spin_unlock_irqrestore(&port->lock, flags); uart_unlock_and_check_sysrq(port, flags);
serial8250_rpm_put(up); serial8250_rpm_put(up);
return 1; return 1;
} }

View File

@ -1755,7 +1755,7 @@ void serial8250_read_char(struct uart_8250_port *up, unsigned char lsr)
else if (lsr & UART_LSR_FE) else if (lsr & UART_LSR_FE)
flag = TTY_FRAME; flag = TTY_FRAME;
} }
if (uart_handle_sysrq_char(port, ch)) if (uart_prepare_sysrq_char(port, ch))
return; return;
uart_insert_char(port, lsr, UART_LSR_OE, ch, flag); uart_insert_char(port, lsr, UART_LSR_OE, ch, flag);
@ -1897,7 +1897,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir)
if ((!up->dma || up->dma->tx_err) && (status & UART_LSR_THRE)) if ((!up->dma || up->dma->tx_err) && (status & UART_LSR_THRE))
serial8250_tx_chars(up); serial8250_tx_chars(up);
spin_unlock_irqrestore(&port->lock, flags); uart_unlock_and_check_sysrq(port, flags);
return 1; return 1;
} }
EXPORT_SYMBOL_GPL(serial8250_handle_irq); EXPORT_SYMBOL_GPL(serial8250_handle_irq);
@ -3258,9 +3258,7 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s,
serial8250_rpm_get(up); serial8250_rpm_get(up);
if (port->sysrq) if (oops_in_progress)
locked = 0;
else if (oops_in_progress)
locked = spin_trylock_irqsave(&port->lock, flags); locked = spin_trylock_irqsave(&port->lock, flags);
else else
spin_lock_irqsave(&port->lock, flags); spin_lock_irqsave(&port->lock, flags);