]> www.infradead.org Git - users/jedix/linux-maple.git/commit
serial: amba-pl011: Fix RTS handling in RS485 mode
authorMiroslav Ondra <ondra@faster.cz>
Sat, 21 Dec 2024 19:11:04 +0000 (20:11 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 23 Dec 2024 18:04:16 +0000 (19:04 +0100)
commit2c1fd53af21b8cb13878b054894d33d3383eb1f3
tree44b9edc63b64d8c6abb77ddb14b52b19954d439b
parentb3ee0bc1a065469cfbcef0c35dc42f138563a1fb
serial: amba-pl011: Fix RTS handling in RS485 mode

Data loss on serial line was observed during communication through
serial ports ttyAMA1 and ttyAMA2 interconnected via RS485 transcievers.
Both ports are in one BCM2711 (Compute Module CM40) and they share
the same interrupt line.

The problem is caused by long waiting for tx queue flush in the function
pl011_rs485_tx_stop. Udelay or mdelay are used to wait.
The function is called from the interrupt handler. If multiple devices
share a single interrupt line, late processing of pending interrupts
and data loss may occur. When operation of both devices are synchronous,
collisions are quite often.

This rework is based on the method used in tty/serial/imx.c
Use hrtimer instead of udelay and mdelay calls.
Replace simple bool variable rs485_tx_started by 4-state variable
rs485_tx_state.

Tested-by: Lino Sanfilippo <l.sanfilippo@kunbus.com>
Signed-off-by: Miroslav Ondra <ondra@faster.cz>
Link: https://lore.kernel.org/r/20241221-amba-rts-v3-1-d3d444681419@faster.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/amba-pl011.c