Skip to contentSkip to conversation

serial: 8250_dw: Take port lock while accessing LSR

PATCH RESEND In review Ilpo Järvinen 2 participants 2 messages Jun 28, 2022

Subsystems (3)
lore
Share & tools
lore

Ilpo Järvinen

author maintainer
#0 lore raw

PATCH RESEND 1/1 serial: 8250_dw: Take port lock while accessing LSR

Accessing LSR requires port lock because it mutates lsr_saved_flags in serial_lsr_in().

Fixes 197eb5c416ff ("serial: 8250_dw: Use serial_lsr_in() in dw8250_handle_irq()")

---
I'll resend the third patch later.

 drivers/tty/serial/8250/8250_dw.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/tty/serial/8250/8250_dw.c +3 -0
index 167a691c7b19..f78b13db1b1e 100644
@@ -266,7 +266,10 @@ static int dw8250_handle_irq(struct uart_port *p)
 
 	/* Manually stop the Rx DMA transfer when acting as flow controller */
 	if (quirks & DW_UART_QUIRK_IS_DMA_FC && up->dma && up->dma->rx_running && rx_timeout) {
+		spin_lock_irqsave(&p->lock, flags);
 		status = serial_lsr_in(up);
+		spin_unlock_irqrestore(&p->lock, flags);
+
 		if (status & (UART_LSR_DR | UART_LSR_BI)) {
 			dw8250_writel_ext(p, RZN1_UART_RDMACR, 0);
 			dw8250_writel_ext(p, DW_UART_DMASA, 1);
Signature · 1 line
tg: (f55d2e4b0a47..) dw/use-spinlock (depends on: 8250/fix-stop_tx-race)
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Ilpo Järvinen

Accessing LSR requires port lock because it mutates lsr_saved_flags in serial_lsr_in().

Don't remember if I given or not (and why if not) the tag, so here it is:

Quoted 27 lines
Fixes 197eb5c416ff ("serial: 8250_dw: Use serial_lsr_in() in dw8250_handle_irq()")

---
I'll resend the third patch later.

 drivers/tty/serial/8250/8250_dw.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/tty/serial/8250/8250_dw.c +3 -0
index 167a691c7b19..f78b13db1b1e 100644
@@ -266,7 +266,10 @@ static int dw8250_handle_irq(struct uart_port *p)
 
 	/* Manually stop the Rx DMA transfer when acting as flow controller */
 	if (quirks & DW_UART_QUIRK_IS_DMA_FC && up->dma && up->dma->rx_running && rx_timeout) {
+		spin_lock_irqsave(&p->lock, flags);
 		status = serial_lsr_in(up);
+		spin_unlock_irqrestore(&p->lock, flags);
+
 		if (status & (UART_LSR_DR | UART_LSR_BI)) {
 			dw8250_writel_ext(p, RZN1_UART_RDMACR, 0);
 			dw8250_writel_ext(p, DW_UART_DMASA, 1);
Signature · 2 lines
-- 
tg: (f55d2e4b0a47..) dw/use-spinlock (depends on: 8250/fix-stop_tx-race)
Signature · 2 lines
With Best Regards,
Andy Shevchenko