Skip to contentSkip to conversation

tty: serial: lpuart: fix the sysrq lockdep issue

PATCH New Andy Duan 1 participant 1 message Nov 22, 2019 TTY layer and serial drivers

lore
Share & tools
lore

Andy Duan

author
#0 lore raw

PATCH 1/1 tty: serial: lpuart: fix the sysrq lockdep issue

From: Fugang Duan <[email protected]>

commit dbdda842fe96 ("printk: Add console owner and waiter logic to load balance console writes") introduces the lockdep issue for lpuart serial driver in sysrq case:

     CPU0                    CPU1
     ----                    ----
lock(&port_lock_key);
                             lock(console_owner);
                             lock(&port_lock_key);

lock(console_owner);

It should unlock port_lock_key in handle_sysrq().

---
 drivers/tty/serial/fsl_lpuart.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/tty/serial/fsl_lpuart.c +4 -4
index 4e128d1..2ddb777 100644
@@ -836,7 +836,7 @@ static void lpuart_rxint(struct lpuart_port *sport)
 		sr = readb(sport->port.membase + UARTSR1);
 		rx = readb(sport->port.membase + UARTDR);
 
-		if (uart_handle_sysrq_char(&sport->port, (unsigned char)rx))
+		if (uart_prepare_sysrq_char(&sport->port, (unsigned char)rx))
 			continue;
 
 		if (sr & (UARTSR1_PE | UARTSR1_OR | UARTSR1_FE)) {
@@ -884,7 +884,7 @@ static void lpuart_rxint(struct lpuart_port *sport)
 		writeb(UARTSFIFO_RXOF, sport->port.membase + UARTSFIFO);
 	}
 
-	spin_unlock_irqrestore(&sport->port.lock, flags);
+	uart_unlock_and_check_sysrq(&sport->port, flags);
 
 	tty_flip_buffer_push(port);
 }
@@ -918,7 +918,7 @@ static void lpuart32_rxint(struct lpuart_port *sport)
 		rx = lpuart32_read(&sport->port, UARTDATA);
 		rx &= 0x3ff;
 
-		if (uart_handle_sysrq_char(&sport->port, (unsigned char)rx))
+		if (uart_prepare_sysrq_char(&sport->port, (unsigned char)rx))
 			continue;
 
 		if (sr & (UARTSTAT_PE | UARTSTAT_OR | UARTSTAT_FE)) {
@@ -955,7 +955,7 @@ static void lpuart32_rxint(struct lpuart_port *sport)
 	}
 
 out:
-	spin_unlock_irqrestore(&sport->port.lock, flags);
+	uart_unlock_and_check_sysrq(&sport->port, flags);
 
 	tty_flip_buffer_push(port);
 }
Signature · 1 line
2.7.4