Skip to content

Commit 8ea0e7b

Browse files
Sean Andersongregkh
authored andcommitted
tty: xilinx_uartps: split sysrq handling
commit b06f388 upstream. 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: Sean Anderson <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d113f97 commit 8ea0e7b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

drivers/tty/serial/xilinx_uartps.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ static void cdns_uart_handle_rx(void *dev_id, unsigned int isrstatus)
268268
continue;
269269
}
270270

271-
if (uart_handle_sysrq_char(port, data))
271+
if (uart_prepare_sysrq_char(port, data))
272272
continue;
273273

274274
if (is_rxbs_support) {
@@ -369,7 +369,7 @@ static irqreturn_t cdns_uart_isr(int irq, void *dev_id)
369369
!(readl(port->membase + CDNS_UART_CR) & CDNS_UART_CR_RX_DIS))
370370
cdns_uart_handle_rx(dev_id, isrstatus);
371371

372-
spin_unlock(&port->lock);
372+
uart_unlock_and_check_sysrq(port);
373373
return IRQ_HANDLED;
374374
}
375375

@@ -1229,10 +1229,8 @@ static void cdns_uart_console_write(struct console *co, const char *s,
12291229
unsigned int imr, ctrl;
12301230
int locked = 1;
12311231

1232-
if (port->sysrq)
1233-
locked = 0;
1234-
else if (oops_in_progress)
1235-
locked = spin_trylock_irqsave(&port->lock, flags);
1232+
if (oops_in_progress)
1233+
locked = uart_port_trylock_irqsave(port, &flags);
12361234
else
12371235
spin_lock_irqsave(&port->lock, flags);
12381236

0 commit comments

Comments
 (0)