Linux Serial subsystem development
 help / color / mirror / Atom feed
* [PATCH] serial: amba-pl011: end an RS485 transmission when TX is flushed
@ 2026-10-21 11:58 Nicolai Buchwitz
  2026-10-21 12:06 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Nicolai Buchwitz @ 2026-10-21 11:58 UTC (permalink / raw)
  To: Russell King, Greg Kroah-Hartman, Jiri Slaby, Lino Sanfilippo
  Cc: linux-kernel, linux-serial, stable, Nicolai Buchwitz

A TX flush during an RS485 DMA transmission only stops the DMA. Nothing
ends the transmission afterwards, so RTS stays asserted and the bus
stays driven until the next write.

End it from the flush, unless the TX interrupt is still enabled and
ends it itself.

Fixes: 8d479237727c ("serial: amba-pl011: add RS485 support")
Cc: stable@vger.kernel.org # 6.18.x
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
A separate issue found while preparing v4 of the RS485 reconfiguration
series:
https://patch.msgid.link/20261021-devel-nbuchwitz-pl011-rs485-reconfig-stall-v4-0-ed10e219159a@tipi-net.de

Tested on a Raspberry Pi CM5 (PL011 on RP1 with TX DMA).
---
 drivers/tty/serial/amba-pl011.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 79776a882ae35..b21de1f2c7807 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -343,6 +343,7 @@ struct uart_amba_port {
 };
 
 static unsigned int pl011_tx_empty(struct uart_port *port);
+static void pl011_rs485_tx_stop(struct uart_amba_port *uap);
 
 static unsigned int pl011_reg_to_offset(const struct uart_amba_port *uap,
 					unsigned int reg)
@@ -874,6 +875,11 @@ __acquires(&uap->port.lock)
 		uap->dmacr &= ~UART011_TXDMAE;
 		pl011_write(uap->dmacr, uap, REG_DMACR);
 	}
+
+	/* Without PIO the TX path won't run again, end an RS485 transmission */
+	if ((port->rs485.flags & SER_RS485_ENABLED) &&
+	    uap->rs485_tx_state == SEND && !(uap->im & UART011_TXIM))
+		pl011_rs485_tx_stop(uap);
 }
 
 static void pl011_dma_rx_callback(void *data);

---
base-commit: 1184f87e2790e8af9be3116f608d2e86b4792d7d
change-id: 20261021-devel-nbuchwitz-pl011-rs485-dma-flush-5f69eafe5b6d

Best regards,
--  
Nicolai Buchwitz <nb@tipi-net.de>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] serial: amba-pl011: end an RS485 transmission when TX is flushed
  2026-10-21 11:58 [PATCH] serial: amba-pl011: end an RS485 transmission when TX is flushed Nicolai Buchwitz
@ 2026-10-21 12:06 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-10-21 12:06 UTC (permalink / raw)
  To: Nicolai Buchwitz; +Cc: linux-serial

> A TX flush during an RS485 DMA transmission only stops the DMA. Nothing
> ends the transmission afterwards, so RTS stays asserted and the bus
> stays driven until the next write.
> 
> End it from the flush, unless the TX interrupt is still enabled and
> ends it itself.
> 
> Fixes: 8d479237727c ("serial: amba-pl011: add RS485 support")
> Cc: stable@vger.kernel.org # 6.18.x
> Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261021-devel-nbuchwitz-pl011-rs485-dma-flush-v1-1-65a78e1fe1b3@tipi-net.de?part=1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-21 12:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-21 11:58 [PATCH] serial: amba-pl011: end an RS485 transmission when TX is flushed Nicolai Buchwitz
2026-10-21 12:06 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox