* [PATCH] serial: amba-pl011: honour delay_rts_before_send for every write
@ 2026-10-11 20:23 Nicolai Buchwitz
2026-10-11 20:30 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Nicolai Buchwitz @ 2026-10-11 20:23 UTC (permalink / raw)
To: Russell King, Greg Kroah-Hartman, Jiri Slaby, Miroslav Ondra
Cc: Lino Sanfilippo, linux-kernel, linux-serial, stable,
Nicolai Buchwitz
While the driver waits out delay_rts_before_send, another write calls
pl011_start_tx() again. pl011_rs485_tx_start() then switches straight
to SEND, and the data goes out before the delay has passed.
Leave the start to the trigger_start_tx timer while it is pending.
Fixes: 2c1fd53af21b ("serial: amba-pl011: Fix RTS handling in RS485 mode")
Cc: stable@vger.kernel.org
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
Noticed while implementing a DMX master on a CM5 with its PL011.
Tested on that board with delay_rts_before_send set to 1 ms and two
quick writes. With ftrace, the first pl011_tx_chars() came 0.03 ms
after pl011_start_tx() before this patch and 1.03 ms after with it.
---
drivers/tty/serial/amba-pl011.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index c4824c201e1c..759124a2a1a8 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1420,10 +1420,6 @@ static void pl011_rs485_tx_start(struct uart_amba_port *uap)
struct uart_port *port = &uap->port;
u32 cr;
- if (uap->rs485_tx_state == WAIT_AFTER_RTS) {
- uap->rs485_tx_state = SEND;
- return;
- }
if (uap->rs485_tx_state == WAIT_AFTER_SEND ||
uap->rs485_tx_state == WAIT_AFTER_SEND_DELAY) {
hrtimer_try_to_cancel(&uap->trigger_stop_tx);
@@ -1462,6 +1458,10 @@ static void pl011_start_tx(struct uart_port *port)
if ((uap->port.rs485.flags & SER_RS485_ENABLED) &&
uap->rs485_tx_state != SEND) {
+ /* trigger_start_tx starts TX once delay_rts_before_send passed */
+ if (uap->rs485_tx_state == WAIT_AFTER_RTS)
+ return;
+
pl011_rs485_tx_start(uap);
if (uap->rs485_tx_state == WAIT_AFTER_RTS)
return;
@@ -1478,8 +1478,10 @@ static enum hrtimer_restart pl011_trigger_start_tx(struct hrtimer *t)
unsigned long flags;
uart_port_lock_irqsave(&uap->port, &flags);
- if (uap->rs485_tx_state == WAIT_AFTER_RTS)
+ if (uap->rs485_tx_state == WAIT_AFTER_RTS) {
+ uap->rs485_tx_state = SEND;
pl011_start_tx(&uap->port);
+ }
uart_port_unlock_irqrestore(&uap->port, flags);
return HRTIMER_NORESTART;
---
base-commit: a90ee4305c4a5df72c11b31dacfdc76e00fcf78a
change-id: 20261011-fix-pl011-rs485-rts-delay-cad4edad250b
Best regards,
--
Nicolai Buchwitz <nb@tipi-net.de>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] serial: amba-pl011: honour delay_rts_before_send for every write
2026-10-11 20:23 [PATCH] serial: amba-pl011: honour delay_rts_before_send for every write Nicolai Buchwitz
@ 2026-10-11 20:30 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-10-11 20:30 UTC (permalink / raw)
To: Nicolai Buchwitz; +Cc: linux-serial
> While the driver waits out delay_rts_before_send, another write calls
> pl011_start_tx() again. pl011_rs485_tx_start() then switches straight
> to SEND, and the data goes out before the delay has passed.
>
> Leave the start to the trigger_start_tx timer while it is pending.
>
> Fixes: 2c1fd53af21b ("serial: amba-pl011: Fix RTS handling in RS485 mode")
> Cc: stable@vger.kernel.org
> Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261011-fix-pl011-rs485-rts-delay-v1-1-5078e61bc408@tipi-net.de?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-11 20:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-11 20:23 [PATCH] serial: amba-pl011: honour delay_rts_before_send for every write Nicolai Buchwitz
2026-10-11 20:30 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox