Skip to content

Commit 0e4f7f9

Browse files
Leo Yangregkh
authored andcommitted
tty: serial: msm_serial: Fix lockup for sysrq and oops
As the commit 677fe55 ("serial: imx: Fix recursive locking bug") has mentioned the uart driver might cause recursive locking between normal printing and the kernel debugging facilities (e.g. sysrq and oops). In the commit it gave out suggestion for fixing recursive locking issue: "The solution is to avoid locking in the sysrq case and trylock in the oops_in_progress case." This patch follows the suggestion (also used the exactly same code with other serial drivers, e.g. amba-pl011.c) to fix the recursive locking issue, this can avoid stuck caused by deadlock and print out log for sysrq and oops. Fixes: 04896a7 ("msm_serial: serial driver for MSM7K onboard serial peripheral.") Signed-off-by: Leo Yan <[email protected]> Reviewed-by: Jeffrey Hugo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e42617b commit 0e4f7f9

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/tty/serial/msm_serial.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,6 +1580,7 @@ static void __msm_console_write(struct uart_port *port, const char *s,
15801580
int num_newlines = 0;
15811581
bool replaced = false;
15821582
void __iomem *tf;
1583+
int locked = 1;
15831584

15841585
if (is_uartdm)
15851586
tf = port->membase + UARTDM_TF;
@@ -1592,7 +1593,13 @@ static void __msm_console_write(struct uart_port *port, const char *s,
15921593
num_newlines++;
15931594
count += num_newlines;
15941595

1595-
spin_lock(&port->lock);
1596+
if (port->sysrq)
1597+
locked = 0;
1598+
else if (oops_in_progress)
1599+
locked = spin_trylock(&port->lock);
1600+
else
1601+
spin_lock(&port->lock);
1602+
15961603
if (is_uartdm)
15971604
msm_reset_dm_count(port, count);
15981605

@@ -1628,7 +1635,9 @@ static void __msm_console_write(struct uart_port *port, const char *s,
16281635
iowrite32_rep(tf, buf, 1);
16291636
i += num_chars;
16301637
}
1631-
spin_unlock(&port->lock);
1638+
1639+
if (locked)
1640+
spin_unlock(&port->lock);
16321641
}
16331642

16341643
static void msm_console_write(struct console *co, const char *s,

0 commit comments

Comments
 (0)