From patchwork Thu Sep 21 16:18:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martyn Welch X-Patchwork-Id: 9964253 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B71756020C for ; Thu, 21 Sep 2017 16:21:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A363B29554 for ; Thu, 21 Sep 2017 16:21:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97CF629577; Thu, 21 Sep 2017 16:21:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 332D929550 for ; Thu, 21 Sep 2017 16:21:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=b4VaJmFFrXpmbApIDHEuxRtorxKOE4yYEczQU/btkkY=; b=F5SqjmoH5h3L9hjAM05uUQ0JEM GCqtrMOZQ/9GLYVohW2sbA4xl5fLepRBrRdrfqZpRcLcoU4ikTbDGFtwz4BujYF9PPP1ZdSetrz2H xf2O2v02oEbB27qaOFEiWAMQ9D7AfvhGxZFofW5xENhbU8HcJoGB1EEhRXJDzh00NzWBJQQrHHYyQ vFvQkxLsnkNYaTX1mXk9PwRrcV8DAgLKhS2/E4bETWAtv2Vb2c3CTqBEaZXHM6V2reaV6rJ0IPX5l pP+xvgPu9Yyn8MdIarJIGVE0WokH7/zAWLUOcZDznNnHUNXzLLUffF7CH8+4Mf4hBZcaFA050w63f KBkCom0g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dv4EA-0005fP-E8; Thu, 21 Sep 2017 16:21:26 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dv4C5-0002hP-Bg for linux-arm-kernel@lists.infradead.org; Thu, 21 Sep 2017 16:19:21 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: martyn) with ESMTPSA id C2F2D268CD1 Received: by kratos.localdomain (Postfix, from userid 1000) id DD531204D84BD; Thu, 21 Sep 2017 17:18:22 +0100 (BST) From: Martyn Welch To: Greg Kroah-Hartman Subject: [PATCH v3 5/6] serial: imx: update the stop rx,tx procedures Date: Thu, 21 Sep 2017 17:18:16 +0100 Message-Id: <1506010697-22114-6-git-send-email-martyn.welch@collabora.co.uk> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1506010697-22114-1-git-send-email-martyn.welch@collabora.co.uk> References: <1506010697-22114-1-git-send-email-martyn.welch@collabora.co.uk> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170921_091918_038292_15DDE6DE X-CRM114-Status: GOOD ( 12.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Martyn Welch , Nandor Han , linux-kernel@vger.kernel.org, Fabio Estevam , linux-serial@vger.kernel.org, u.kleine-koenig@pengutronix.de, Romain Perier , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Nandor Han According to "Documentation/serial/driver" both procedures should stop receiving or sending data. Based on this the procedures should stop the activity regardless if DMA is enabled or not. This commit updates both imx_stop_{rx|tx} procedures to stop the activity and disable the interrupts related to that. Signed-off-by: Nandor Han Signed-off-by: Romain Perier Signed-off-by: Martyn Welch --- drivers/tty/serial/imx.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index ed02783..256b128 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -388,15 +388,14 @@ static void imx_stop_tx(struct uart_port *port) struct imx_port *sport = (struct imx_port *)port; unsigned long temp; - /* - * We are maybe in the SMP context, so if the DMA TX thread is running - * on other cpu, we have to wait for it to finish. - */ - if (sport->dma_is_enabled && sport->dma_is_txing) - return; + sport->tx_bytes = 0; + + if (sport->dma_is_enabled) + imx_stop_tx_dma(sport); temp = readl(port->membase + UCR1); - writel(temp & ~UCR1_TXMPTYEN, port->membase + UCR1); + temp &= ~(UCR1_TXMPTYEN | UCR1_TRDYEN | UCR1_RTSDEN); + writel(temp, port->membase + UCR1); /* in rs485 mode disable transmitter if shifter is empty */ if (port->rs485.flags & SER_RS485_ENABLED && @@ -423,21 +422,20 @@ static void imx_stop_rx(struct uart_port *port) struct imx_port *sport = (struct imx_port *)port; unsigned long temp; - if (sport->dma_is_enabled && sport->dma_is_rxing) { - if (sport->port.suspended) { - dmaengine_terminate_all(sport->dma_chan_rx); - sport->dma_is_rxing = 0; - } else { - return; - } - } + if (sport->dma_is_enabled) + imx_stop_rx_dma(sport); + + temp = readl(sport->port.membase + UCR1); + temp &= ~UCR1_RRDYEN; + writel(temp, sport->port.membase + UCR1); temp = readl(sport->port.membase + UCR2); - writel(temp & ~UCR2_RXEN, sport->port.membase + UCR2); + temp &= ~UCR2_ATEN; + writel(temp, sport->port.membase + UCR2); - /* disable the `Receiver Ready Interrrupt` */ - temp = readl(sport->port.membase + UCR1); - writel(temp & ~UCR1_RRDYEN, sport->port.membase + UCR1); + temp = readl(sport->port.membase + UCR3); + temp &= ~UCR3_AWAKEN; + writel(temp, sport->port.membase + UCR3); } /*