[PATCH] serial: mxs-auart: wait for DMA buffer to flush before shutdown

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The shutdown function was not waiting for the DMA buffer to flush
before disabling the AUART. This lead to many bytes not being
transferred (specially at low baudrates), as they were still in the
DMA buffer when the AUART was shutdown.
This patch also adds the check for the BUSY flag.

Signed-off-by: Hector Palacios <hector.palacios@xxxxxxxx>

https://jira.digi.com/browse/DEL-616
---
 drivers/tty/serial/mxs-auart.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index f85b8e6..0d8b2ca 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -750,12 +750,26 @@ static int mxs_auart_startup(struct uart_port *u)
 	return 0;
 }
 
+static unsigned int mxs_auart_tx_empty(struct uart_port *u);
+
 static void mxs_auart_shutdown(struct uart_port *u)
 {
 	struct mxs_auart_port *s = to_auart_port(u);
+	unsigned int to;
+
+	if (auart_dma_enabled(s)) {
+		/* Wait enough time to flush DMA buffer completely */
+		to = u->timeout * UART_XMIT_SIZE / u->fifosize;
+		while (!mxs_auart_tx_empty(u) && to--)
+			mdelay(1);
 
-	if (auart_dma_enabled(s))
 		mxs_auart_dma_exit(s);
+	}
+
+	/* Wait for transmitter to become empty ... */
+	to = u->timeout;
+	while ((readl(port->membase + AUART_STAT) & AUART_STAT_BUSY) && to--)
+		mdelay(1);
 
 	writel(AUART_CTRL2_UARTEN, u->membase + AUART_CTRL2_CLR);
 
-- 
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux