From patchwork Fri Jun 30 12:04:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Perier X-Patchwork-Id: 9819453 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 CDC666035F for ; Fri, 30 Jun 2017 12:07:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF0B32862C for ; Fri, 30 Jun 2017 12:07:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3DFF2863C; Fri, 30 Jun 2017 12:07:13 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 3DBCE2862C for ; Fri, 30 Jun 2017 12:07:13 +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=QER4t3gH8tANn9cVXZj0gSeSWYR+REbB/8q0+zc3S+g=; b=Snw21Tp3HNfwhcxwGjwd5tlsMX O/AuhyrkG9RvDMLbnalOutJfEldQNmANaZj+fiSP6wFfKDqzZS2CPjN3UuH8iW/tc+0fwrJIeGckZ BIpRSfGO/RvZ705iGumQN+IUme8ADDMSdPbRPzeQRmapLi0IPX2s6gnvgzbDxnC0bpB0lGTT4Jfkg 9+164IjqyWTiKO963lEwNAEsbY+oqYbN70An5ZPU774oXon7IBplbVG/1VnYBaPVk5JvMeGbhj5ka LBZlVeCon0ZXLupK8RDzY4bJDn/EZE8wHtJuvpv6XS59/TXM4a7eqzNnIsAToq67ezH9SgAFzi45z m806pkRA==; 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 1dQuhZ-0001RT-3L; Fri, 30 Jun 2017 12:07:09 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dQugA-00083S-IO for linux-arm-kernel@lists.infradead.org; Fri, 30 Jun 2017 12:05:47 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: rperier) with ESMTPSA id D3F0A26BF82 From: Romain Perier To: Greg Kroah-Hartman Subject: [PATCH 6/7] serial: imx: update the stop rx,tx procedures Date: Fri, 30 Jun 2017 14:04:45 +0200 Message-Id: <20170630120446.13994-7-romain.perier@collabora.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630120446.13994-1-romain.perier@collabora.com> References: <20170630120446.13994-1-romain.perier@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170630_050542_939714_C567181E X-CRM114-Status: GOOD ( 12.38 ) 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: Romain Perier , Nandor Han , linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.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. In case DMA is used the sg buffers are also un-maped. Signed-off-by: Nandor Han Signed-off-by: Romain Perier --- drivers/tty/serial/imx.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 58d6b1c..d5b6e09 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -360,6 +360,9 @@ static void imx_port_rts_auto(struct imx_port *sport, unsigned long *ucr2) *ucr2 |= UCR2_CTSC; } +static void imx_stop_rx_dma(struct imx_port *sport); +static void imx_stop_tx_dma(struct imx_port *sport); + /* * interrupts disabled on entry */ @@ -368,15 +371,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 && @@ -403,21 +405,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); } /*