Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751703AbdHLPWr (ORCPT ); Sat, 12 Aug 2017 11:22:47 -0400 Received: from mail.pqgruber.com ([178.189.19.235]:47627 "EHLO mail.pqgruber.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750983AbdHLPWq (ORCPT ); Sat, 12 Aug 2017 11:22:46 -0400 X-Greylist: delayed 592 seconds by postgrey-1.27 at vger.kernel.org; Sat, 12 Aug 2017 11:22:45 EDT From: Clemens Gruber To: linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman , Fabio Estevam , linux-kernel@vger.kernel.org, Clemens Gruber , Ian Jamison , =?UTF-8?q?Uwe-Kleine=20K=C3=B6nig?= Subject: [PATCH] serial: imx: Improve PIO prevention if TX DMA has been started Date: Sat, 12 Aug 2017 17:12:10 +0200 Message-Id: <20170812151210.10420-1-clemens.gruber@pqgruber.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1306 Lines: 37 The imx_transmit_buffer function should return if TX DMA has already been started and not just skip over the buffer PIO write loop. (Which did fix the initial problem, but could have unintentional side-effects) Tested on an i.MX6Q board with half-duplex RS-485 and with RS-232. Cc: Ian Jamison Cc: Uwe-Kleine König Fixes: 514ab34dbad6 ("serial: imx: Prevent TX buffer PIO write when a DMA has been started") Signed-off-by: Clemens Gruber --- drivers/tty/serial/imx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 80934e7bd67f..fce538eb8c77 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -452,13 +452,14 @@ static inline void imx_transmit_buffer(struct imx_port *sport) if (sport->dma_is_txing) { temp |= UCR1_TDMAEN; writel(temp, sport->port.membase + UCR1); + return; } else { writel(temp, sport->port.membase + UCR1); imx_dma_tx(sport); } } - while (!uart_circ_empty(xmit) && !sport->dma_is_txing && + while (!uart_circ_empty(xmit) && !(readl(sport->port.membase + uts_reg(sport)) & UTS_TXFULL)) { /* send xmit->buf[xmit->tail] * out the port here */ -- 2.14.1