diff options
author | Richard Genoud <richard.genoud@gmail.com> | 2016-12-06 07:05:33 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-01-11 02:18:45 -0500 |
commit | b389f173aaa1204d6dc1f299082a162eb0491545 (patch) | |
tree | d702ef5021258fc6894bec24dcb2e68a06a3c0a5 /drivers/tty | |
parent | 89d8232411a85b9a6b12fd5da4d07d8a138a8e0c (diff) |
tty/serial: atmel: RS485 half duplex w/DMA: enable RX after TX is done
When using RS485 in half duplex, RX should be enabled when TX is
finished, and stopped when TX starts.
Before commit 0058f0871efe7b01c6 ("tty/serial: atmel: fix RS485 half
duplex with DMA"), RX was not disabled in atmel_start_tx() if the DMA
was used. So, collisions could happened.
But disabling RX in atmel_start_tx() uncovered another bug:
RX was enabled again in the wrong place (in atmel_tx_dma) instead of
being enabled when TX is finished (in atmel_complete_tx_dma), so the
transmission simply stopped.
This bug was not triggered before commit 0058f0871efe7b01c6
("tty/serial: atmel: fix RS485 half duplex with DMA") because RX was
never disabled before.
Moving atmel_start_rx() in atmel_complete_tx_dma() corrects the problem.
Cc: stable@vger.kernel.org
Reported-by: Gil Weber <webergil@gmail.com>
Fixes: 0058f0871efe7b01c6
Tested-by: Gil Weber <webergil@gmail.com>
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/serial/atmel_serial.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index f9d42de5ab2d..fabbe76203bb 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c | |||
@@ -809,6 +809,11 @@ static void atmel_complete_tx_dma(void *arg) | |||
809 | */ | 809 | */ |
810 | if (!uart_circ_empty(xmit)) | 810 | if (!uart_circ_empty(xmit)) |
811 | atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx); | 811 | atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx); |
812 | else if ((port->rs485.flags & SER_RS485_ENABLED) && | ||
813 | !(port->rs485.flags & SER_RS485_RX_DURING_TX)) { | ||
814 | /* DMA done, stop TX, start RX for RS485 */ | ||
815 | atmel_start_rx(port); | ||
816 | } | ||
812 | 817 | ||
813 | spin_unlock_irqrestore(&port->lock, flags); | 818 | spin_unlock_irqrestore(&port->lock, flags); |
814 | } | 819 | } |
@@ -911,12 +916,6 @@ static void atmel_tx_dma(struct uart_port *port) | |||
911 | desc->callback = atmel_complete_tx_dma; | 916 | desc->callback = atmel_complete_tx_dma; |
912 | desc->callback_param = atmel_port; | 917 | desc->callback_param = atmel_port; |
913 | atmel_port->cookie_tx = dmaengine_submit(desc); | 918 | atmel_port->cookie_tx = dmaengine_submit(desc); |
914 | |||
915 | } else { | ||
916 | if (port->rs485.flags & SER_RS485_ENABLED) { | ||
917 | /* DMA done, stop TX, start RX for RS485 */ | ||
918 | atmel_start_rx(port); | ||
919 | } | ||
920 | } | 919 | } |
921 | 920 | ||
922 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) | 921 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) |