linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Romain Perier <romain.perier@collabora.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-serial@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Nandor Han <nandor.han@ge.com>,
	Romain Perier <romain.perier@collabora.com>
Subject: [PATCH 6/7] serial: imx: update the stop rx,tx procedures
Date: Fri, 30 Jun 2017 14:04:45 +0200	[thread overview]
Message-ID: <20170630120446.13994-7-romain.perier@collabora.com> (raw)
In-Reply-To: <20170630120446.13994-1-romain.perier@collabora.com>

From: Nandor Han <nandor.han@ge.com>

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 <nandor.han@ge.com>
Signed-off-by: Romain Perier <romain.perier@collabora.com>
---
 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);
 }
 
 /*
-- 
1.8.3.1

  parent reply	other threads:[~2017-06-30 12:05 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-30 12:04 [PATCH 0/7] serial: imx: various improvements Romain Perier
2017-06-30 12:04 ` [PATCH 1/7] serial: imx: only set DMA rx-ing when DMA starts Romain Perier
2017-07-03  6:48   ` Uwe Kleine-König
2017-07-04  8:55     ` Romain Perier
2017-06-30 12:04 ` [PATCH 2/7] serial: imx: move log from error to debug type Romain Perier
2017-07-03  6:50   ` Uwe Kleine-König
2017-06-30 12:04 ` [PATCH 3/7] serial: imx: init dma_is_{rx|tx}ing variables Romain Perier
2017-06-30 12:13   ` Lothar Waßmann
2017-07-03  6:52     ` Uwe Kleine-König
2017-07-05 10:14       ` Romain Perier
2017-07-05 11:58         ` Uwe Kleine-König
2017-06-30 12:04 ` [PATCH 4/7] serial: imx: Simplify DMA disablement Romain Perier
2017-07-03  6:58   ` Uwe Kleine-König
2017-06-30 12:04 ` [PATCH 5/7] serial: imx: umap sg buffers when DMA channel is released Romain Perier
2017-07-03  7:01   ` Uwe Kleine-König
2017-06-30 12:04 ` Romain Perier [this message]
2017-07-03  7:03   ` [PATCH 6/7] serial: imx: update the stop rx,tx procedures Uwe Kleine-König
2017-06-30 12:04 ` [PATCH 7/7] serial: imx: Fix imx_shutdown procedure Romain Perier
2017-07-03  7:08   ` Uwe Kleine-König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170630120446.13994-7-romain.perier@collabora.com \
    --to=romain.perier@collabora.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=nandor.han@ge.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).