Skip to content

Commit b06f388

Browse files
Sean Andersongregkh
authored andcommitted
tty: xilinx_uartps: split sysrq handling
lockdep detects the following circular locking dependency: CPU 0 CPU 1 ========================== ============================ cdns_uart_isr() printk() uart_port_lock(port) console_lock() cdns_uart_console_write() if (!port->sysrq) uart_port_lock(port) uart_handle_break() port->sysrq = ... uart_handle_sysrq_char() printk() console_lock() The fixed commit attempts to avoid this situation by only taking the port lock in cdns_uart_console_write if port->sysrq unset. However, if (as shown above) cdns_uart_console_write runs before port->sysrq is set, then it will try to take the port lock anyway. This may result in a deadlock. Fix this by splitting sysrq handling into two parts. We use the prepare helper under the port lock and defer handling until we release the lock. Fixes: 74ea66d ("tty: xuartps: Improve sysrq handling") Signed-off-by: Sean Anderson <[email protected]> Cc: [email protected] # c980248: serial: xilinx_uartps: Use port lock wrappers Acked-by: John Ogness <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 568bfce commit b06f388

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/tty/serial/xilinx_uartps.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ static void cdns_uart_handle_rx(void *dev_id, unsigned int isrstatus)
287287
continue;
288288
}
289289

290-
if (uart_handle_sysrq_char(port, data))
290+
if (uart_prepare_sysrq_char(port, data))
291291
continue;
292292

293293
if (is_rxbs_support) {
@@ -495,7 +495,7 @@ static irqreturn_t cdns_uart_isr(int irq, void *dev_id)
495495
!(readl(port->membase + CDNS_UART_CR) & CDNS_UART_CR_RX_DIS))
496496
cdns_uart_handle_rx(dev_id, isrstatus);
497497

498-
uart_port_unlock(port);
498+
uart_unlock_and_check_sysrq(port);
499499
return IRQ_HANDLED;
500500
}
501501

@@ -1380,9 +1380,7 @@ static void cdns_uart_console_write(struct console *co, const char *s,
13801380
unsigned int imr, ctrl;
13811381
int locked = 1;
13821382

1383-
if (port->sysrq)
1384-
locked = 0;
1385-
else if (oops_in_progress)
1383+
if (oops_in_progress)
13861384
locked = uart_port_trylock_irqsave(port, &flags);
13871385
else
13881386
uart_port_lock_irqsave(port, &flags);

0 commit comments

Comments
 (0)