Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1541284

[PATCH] tty/serial: atmel_serial: BUG: stop DMA from transmitting in stop_tx

From Richard Genoud <richard.genoud@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] tty/serial: atmel_serial: BUG: stop DMA from transmitting in stop_tx
Date 2016-12-13 18:20 +0100
Message-ID <sNYUa-3UP-37@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


If we don't disable the transmitter in atmel_stop_tx, the DMA buffer
continues to send data until it is emptied.
This cause problems with the flow control (CTS is asserted and data are
still sent).

So, disabling the transmitter in atmel_stop_tx is a sane thing to do.

Tested on at91sam9g35-cm(DMA)
Tested for regressions on sama5d2-xplained(Fifo) and at91sam9g20ek(PDC)

Cc: <stable@vger.kernel.org> (beware, this won't apply before 4.3)
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
---
 drivers/tty/serial/atmel_serial.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

NB: this is not for the 4.10 merge window, I'm just sending it now to
have some comments if someone is againts it.

diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 168b10cad47b..f9d42de5ab2d 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -481,6 +481,14 @@ static void atmel_stop_tx(struct uart_port *port)
 		/* disable PDC transmit */
 		atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS);
 	}
+
+	/*
+	 * Disable the transmitter.
+	 * This is mandatory when DMA is used, otherwise the DMA buffer
+	 * is fully transmitted.
+	 */
+	atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS);
+
 	/* Disable interrupts */
 	atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask);
 
@@ -513,6 +521,9 @@ static void atmel_start_tx(struct uart_port *port)
 
 	/* Enable interrupts */
 	atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask);
+
+	/* re-enable the transmitter */
+	atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN);
 }
 
 /*

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] tty/serial: atmel_serial: BUG: stop DMA from transmitting in stop_tx Richard Genoud <richard.genoud@gmail.com> - 2016-12-13 18:20 +0100
  Re: [PATCH] tty/serial: atmel_serial: BUG: stop DMA from transmitting  in stop_tx Nicolas Ferre <nicolas.ferre@atmel.com> - 2017-01-02 12:20 +0100
    Re: [PATCH] tty/serial: atmel_serial: BUG: stop DMA from transmitting  in stop_tx Richard Genoud <richard.genoud@gmail.com> - 2017-01-02 15:20 +0100

csiph-web