⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@pelwell
Copy link
Contributor

@pelwell pelwell commented Dec 18, 2025

commit 2c1fd53 upstream.

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

Link: https://lore.kernel.org/r/20241221-amba-rts-v3-1-d3d444681419@faster.cz

@nbuchwitz
Copy link
Contributor

hrtimer_init(&uap->trigger_start_tx, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
hrtimer_init(&uap->trigger_stop_tx, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
uap->trigger_start_tx.function = pl011_trigger_start_tx;
uap->trigger_stop_tx.function = pl011_trigger_stop_tx;

is missing in pl011_axi_probe() in order to make this work with rp1

commit 2c1fd53 upstream.

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>
pl011_axi_probe was missing the equivlent hrtimer initialisation
from commit 2c1fd53 ("serial: amba-pl011: Fix RTS handling in RS485 mode")
and commit 8cb4418 ("serial: amba-pl011: Switch to use hrtimer_setup()")
resulting in the kernel blowing up as soon as pl011_rs485_stop_tx
tried to use them.

Add the hrtimer initialisation.

Fixes: 120c89e ("serial: pl011: rp1 uart support")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
@pelwell
Copy link
Contributor Author

pelwell commented Jan 23, 2026

Like this?

@nbuchwitz
Copy link
Contributor

Yes, that's the same as what I tested here.

There is still a significant performance regression (essentially unusable) with our RS485-based backplane driver. I would really appreciate holding off on the merge until we have investigated this further. Otherwise, we would need to revert this downstream.

@pelwell pelwell marked this pull request as draft January 23, 2026 15:51
@pelwell
Copy link
Contributor Author

pelwell commented Jan 23, 2026

It's going nowhere for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants