All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] tty/serial: atmel: Fix RS485 half duplex operation
@ 2019-03-19 13:20 ` Razvan Stefanescu
  0 siblings, 0 replies; 13+ messages in thread
From: Razvan Stefanescu @ 2019-03-19 13:20 UTC (permalink / raw)
  To: Richard Genoud, Greg Kroah-Hartman, Jiri Slaby
  Cc: Gil Weber, Nicolas Ferre, Alexandre Belloni, Ludovic Desroches,
	linux-serial, linux-arm-kernel, linux-kernel

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(-)

-- 
2.19.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-03-26 15:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-19 13:20 [PATCH v2 0/2] tty/serial: atmel: Fix RS485 half duplex operation Razvan Stefanescu
2019-03-19 13:20 ` Razvan Stefanescu
2019-03-19 13:20 ` Razvan Stefanescu
2019-03-19 13:20 ` [PATCH v2 1/2] tty/serial: atmel: Add is_half_duplex helper Razvan Stefanescu
2019-03-19 13:20   ` Razvan Stefanescu
2019-03-19 13:20   ` Razvan Stefanescu
2019-03-26 15:10   ` Richard Genoud
2019-03-26 15:10     ` Richard Genoud
2019-03-19 13:20 ` [PATCH v2 2/2] tty/serial: atmel: RS485 HD w/DMA: enable RX after TX is stopped Razvan Stefanescu
2019-03-19 13:20   ` Razvan Stefanescu
2019-03-19 13:20   ` Razvan Stefanescu
2019-03-26 15:12   ` Richard Genoud
2019-03-26 15:12     ` Richard Genoud

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.