Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

pch_uart: fix a deadlock when pch_uart as console

When we use pch_uart as system console like 'console=ttyPCH0,115200',
then 'send break' to it. We'll encounter the deadlock on a cpu/core,
with interrupts disabled on the core. When we happen to have all irqs
affinity to cpu0 then the deadlock on cpu0 actually deadlock whole
system.

In pch_uart_interrupt, we have spin_lock_irqsave(&priv->lock, flags)
then call pch_uart_err_ir when break is received. Then the call to
dev_err would actually call to pch_console_write then we'll run into
another spin_lock(&priv->lock), with interrupts disabled.

So in the call sequence lead by pch_uart_interrupt, we should be
carefully to call functions that will 'print message to console' only
in case the uart port is not being used as serial console.

Signed-off-by: Liang Li <liang.li@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Liang Li and committed by
Greg Kroah-Hartman
384e301e 64325a3b

+22 -7
+22 -7
drivers/tty/serial/pch_uart.c
··· 1024 1024 static void pch_uart_err_ir(struct eg20t_port *priv, unsigned int lsr) 1025 1025 { 1026 1026 u8 fcr = ioread8(priv->membase + UART_FCR); 1027 + struct uart_port *port = &priv->port; 1028 + struct tty_struct *tty = tty_port_tty_get(&port->state->port); 1029 + char *error_msg[5] = {}; 1030 + int i = 0; 1027 1031 1028 1032 /* Reset FIFO */ 1029 1033 fcr |= UART_FCR_CLEAR_RCVR; 1030 1034 iowrite8(fcr, priv->membase + UART_FCR); 1031 1035 1032 1036 if (lsr & PCH_UART_LSR_ERR) 1033 - dev_err(&priv->pdev->dev, "Error data in FIFO\n"); 1037 + error_msg[i++] = "Error data in FIFO\n"; 1034 1038 1035 - if (lsr & UART_LSR_FE) 1036 - dev_err(&priv->pdev->dev, "Framing Error\n"); 1039 + if (lsr & UART_LSR_FE) { 1040 + port->icount.frame++; 1041 + error_msg[i++] = " Framing Error\n"; 1042 + } 1037 1043 1038 - if (lsr & UART_LSR_PE) 1039 - dev_err(&priv->pdev->dev, "Parity Error\n"); 1044 + if (lsr & UART_LSR_PE) { 1045 + port->icount.parity++; 1046 + error_msg[i++] = " Parity Error\n"; 1047 + } 1040 1048 1041 - if (lsr & UART_LSR_OE) 1042 - dev_err(&priv->pdev->dev, "Overrun Error\n"); 1049 + if (lsr & UART_LSR_OE) { 1050 + port->icount.overrun++; 1051 + error_msg[i++] = " Overrun Error\n"; 1052 + } 1053 + 1054 + if (tty == NULL) { 1055 + for (i = 0; error_msg[i] != NULL; i++) 1056 + dev_err(&priv->pdev->dev, error_msg[i]); 1057 + } 1043 1058 } 1044 1059 1045 1060 static irqreturn_t pch_uart_interrupt(int irq, void *dev_id)