Skip to contentSkip to conversation

serial: 8250_fsl: fix handle_irq locking

PATCH In review Johan Hovold 2 participants 2 messages Feb 27, 2023 – Feb 28, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: 8250_fsl: fix handle_irq locking

The 8250 handle_irq callback is not just called from the interrupt handler but also from a timer callback when polling (e.g. for ports without an interrupt line). Consequently the callback must explicitly disable interrupts to avoid a potential deadlock with another interrupt in polled mode.

Fix up the two paths in the freescale callback that failed to re-enable interrupts when polling.

Fixes 853a9ae29e97 ("serial: 8250: fix handle_irq locking")
---
 drivers/tty/serial/8250/8250_fsl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_fsl.c +2 -2
index 8aad15622a2e..8adfaa183f77 100644
@@ -34,7 +34,7 @@ int fsl8250_handle_irq(struct uart_port *port)
 
 	iir = port->serial_in(port, UART_IIR);
 	if (iir & UART_IIR_NO_INT) {
-		spin_unlock(&up->port.lock);
+		spin_unlock_irqrestore(&up->port.lock, flags);
 		return 0;
 	}
 
@@ -42,7 +42,7 @@ int fsl8250_handle_irq(struct uart_port *port)
 	if (unlikely(up->lsr_saved_flags & UART_LSR_BI)) {
 		up->lsr_saved_flags &= ~UART_LSR_BI;
 		port->serial_in(port, UART_RX);
-		spin_unlock(&up->port.lock);
+		spin_unlock_irqrestore(&up->port.lock, flags);
 		return 1;
 	}
 
Signature · 1 line
2.39.2
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Johan Hovold

The 8250 handle_irq callback is not just called from the interrupt handler but also from a timer callback when polling (e.g. for ports without an interrupt line). Consequently the callback must explicitly disable interrupts to avoid a potential deadlock with another interrupt in polled mode.

Fix up the two paths in the freescale callback that failed to re-enable interrupts when polling.

Huh.

Signature · 2 lines
js
suse labs