Commit 0ba9aee
serial: pl011: Add configurable bounded polling for RS485 TX drain
The hrtimer-based TX drain introduced in commit 2c1fd53 ("serial:
amba-pl011: Fix RTS handling in RS485 mode") can cause RX errors in
fast request/response RS485 protocols. The hrtimer callback latency
(often 50-100µs per iteration) delays RX re-enable, causing the first
bytes of slave responses to be lost.
Add a configurable bounded polling mode that spins for TX completion
with a timeout, falling back to hrtimer only if the timeout is exceeded.
This is controlled by two new device tree properties:
rs485-tx-drain-poll - enable bounded polling mode
rs485-tx-drain-timeout-us - explicit timeout in microseconds (optional)
When rs485-tx-drain-poll is set without an explicit timeout, the timeout
is auto-calculated as (fifo_size + 1) * character_time, accounting for
the FIFO depth plus one character in the shift register. This adapts
automatically to baud rate changes.
The default behavior (no DT properties) remains unchanged, preserving
the pure hrtimer approach for systems where shared IRQ latency is the
primary concern.
Signed-off-by: Nicolai Buchwitz <n.buchwitz@kunbus.com>1 parent 1e70af9 commit 0ba9aee
1 file changed
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
| 289 | + | |
| 290 | + | |
289 | 291 | | |
290 | 292 | | |
291 | 293 | | |
| |||
1288 | 1290 | | |
1289 | 1291 | | |
1290 | 1292 | | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
1291 | 1306 | | |
1292 | 1307 | | |
1293 | 1308 | | |
| |||
1297 | 1312 | | |
1298 | 1313 | | |
1299 | 1314 | | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
1300 | 1328 | | |
1301 | 1329 | | |
1302 | 1330 | | |
| |||
2904 | 2932 | | |
2905 | 2933 | | |
2906 | 2934 | | |
| 2935 | + | |
| 2936 | + | |
| 2937 | + | |
| 2938 | + | |
| 2939 | + | |
2907 | 2940 | | |
2908 | 2941 | | |
2909 | 2942 | | |
| |||
3103 | 3136 | | |
3104 | 3137 | | |
3105 | 3138 | | |
| 3139 | + | |
| 3140 | + | |
| 3141 | + | |
| 3142 | + | |
| 3143 | + | |
3106 | 3144 | | |
3107 | 3145 | | |
3108 | 3146 | | |
| |||
0 commit comments