Skip to content

tty/serial: atmel: Fix RS485 half duplex operation

Razvan Stefanescu linux-arm-kernel linux-serial lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 2 repliesIn review
  2. v12 patches 4 repliesSuperseded

Changes in v2 from the cover letter

- remove wrongly added check;
- start rx and display warning message in case of error
- add fix info

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2tty/serial: atmel: Add is_half_duplex helperdrivers/tty/serial/atmel_serial.c+12 -121 reply
2/2tty/serial: atmel: RS485 HD w/DMA: enable RX after TX is stoppeddrivers/tty/serial/atmel_serial.c+21 -31 reply

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchRichard Genoud
1/2A-b
2/2A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] tty/serial: atmel: Fix RS485 half duplex operation

Using a loopback serial cable with RS485 protocol shows that data is received:

$ stty -F /dev/ttyS3 raw -echo speed 4800
$ cat /dev/ttyS3 &
$ echo "Hello, world" > /dev/ttyS3
Hello, world

Last line should not be displayed, as it indicates that RX was started before TX finished.

This happens because driver activates RX when the DMA transfer completes, but that does not necessarily mean the TX FIFO was emptied.

First patch will add a helper that checks if the transmission is half-duplex and uses it throughout the driver, replacing multiple lines of code.

Second patch implements the fix by adding a variable to the port struct. This is used to indicate that RX needs to be started. When the DMA transfer completes, the variable is set and the ATMEL_US_TXEMPTY is reactivated. In the interrupt handler, if the variable is set, RX is started.

Changelog:
v1 -> v2:
- remove wrongly added check;
- start rx and display warning message in case of error
- add fix info

Razvan Stefanescu (2):
tty/serial: atmel: Add is_half_duplex helper tty/serial: atmel: RS485 HD w/DMA: enable RX after TX is stopped

 drivers/tty/serial/atmel_serial.c | 48 +++++++++++++++++++++----------
 1 file changed, 33 insertions(+), 15 deletions(-)
Signature · 1 line
2.19.1