linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nandor Han <nandor.han@ge.com>
To: =Dan Williams <dan.j.williams@intel.com>,
	Vinod Koul <vinod.koul@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>
Cc: Nandor Han <nandor.han@ge.com>,
	dmaengine@vger.kernel.org, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Peter Senna Tschudin <peter.senna@collabora.com>
Subject: [PATCH 4/4] serial: imx-serial - update RX error counters when DMA is used
Date: Mon,  8 Aug 2016 15:38:28 +0300	[thread overview]
Message-ID: <1f338636da75ccdf330e3e1164a023219faa56e0.1470656658.git.nandor.han@ge.com> (raw)
In-Reply-To: <cover.1470656657.git.nandor.han@ge.com>
In-Reply-To: <cover.1470656657.git.nandor.han@ge.com>

Update error counters when DMA is used for receiving data. Do
this by using DMA transaction error event instead error interrupts
to reduce interrupt load.

Tested-by: Peter Senna Tschudin <peter.senna@collabora.com>
Acked-by: Peter Senna Tschudin <peter.senna@collabora.com>
Signed-off-by: Nandor Han <nandor.han@ge.com>
---
 drivers/tty/serial/imx.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 1912136..08ccfe1 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -704,6 +704,7 @@ out:
 	return IRQ_HANDLED;
 }
 
+static void clear_rx_errors(struct imx_port *sport);
 static int start_rx_dma(struct imx_port *sport);
 /*
  * If the RXFIFO is filled with some data, and then we
@@ -729,6 +730,11 @@ static void imx_dma_rxint(struct imx_port *sport)
 		temp &= ~(UCR2_ATEN);
 		writel(temp, sport->port.membase + UCR2);
 
+		/* disable the rx errors interrupts */
+		temp = readl(sport->port.membase + UCR4);
+		temp &= ~UCR4_OREN;
+		writel(temp, sport->port.membase + UCR4);
+
 		/* tell the DMA to receive the data. */
 		start_rx_dma(sport);
 	}
@@ -961,6 +967,7 @@ static void dma_rx_callback(void *data)
 
 	if (status == DMA_ERROR) {
 		dev_err(sport->port.dev, "DMA transaction error.\n");
+		clear_rx_errors(sport);
 		return;
 	}
 
@@ -1057,6 +1064,31 @@ static int start_rx_dma(struct imx_port *sport)
 	return 0;
 }
 
+static void clear_rx_errors(struct imx_port *sport)
+{
+	unsigned int status_usr1, status_usr2;
+
+	status_usr1 = readl(sport->port.membase + USR1);
+	status_usr2 = readl(sport->port.membase + USR2);
+
+	if (status_usr2 & USR2_BRCD) {
+		sport->port.icount.brk++;
+		writel(USR2_BRCD, sport->port.membase + USR2);
+	} else if (status_usr1 & USR1_FRAMERR) {
+		sport->port.icount.frame++;
+		writel(USR1_FRAMERR, sport->port.membase + USR1);
+	} else if (status_usr1 & USR1_PARITYERR) {
+		sport->port.icount.parity++;
+		writel(USR1_PARITYERR, sport->port.membase + USR1);
+	}
+
+	if (status_usr2 & USR2_ORE) {
+		sport->port.icount.overrun++;
+		writel(USR2_ORE, sport->port.membase + USR2);
+	}
+
+}
+
 #define TXTL_DEFAULT 2 /* reset default */
 #define RXTL_DEFAULT 1 /* reset default */
 #define TXTL_DMA 8 /* DMA burst setting */
-- 
2.8.3

      parent reply	other threads:[~2016-08-08 12:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-09 12:16 [PATCH RFC 0/4] serial,dma: use DMA cyclic for IMX UART driver Nandor Han
2016-06-09 12:16 ` [PATCH RFC 1/4] dma: imx-sdma - reduce transfer latency for DMA cyclic clients Nandor Han
2016-06-28 14:34   ` Vinod Koul
2016-07-01 14:59     ` EXT: " Nandor Han
2016-07-02 17:27       ` Vinod Koul
2016-07-14  8:32   ` Peter Senna Tschudin
2016-06-09 12:16 ` [PATCH RFC 2/4] dma: imx-sdma - update the residue calculation for cyclic channels Nandor Han
2016-06-09 12:16 ` [PATCH RFC 3/4] serial: imx-serial - update UART IMX driver to use cyclic DMA Nandor Han
2016-06-09 12:16 ` [PATCH RFC 4/4] serial: imx-serial - update RX error counters when DMA is used Nandor Han
2016-08-08 12:38 ` [PATCH 0/4] serial,dmaengine: use DMA cyclic for IMX UART driver Nandor Han
2016-08-08 12:38   ` [PATCH 1/4] dmaengine: imx-sdma - reduce transfer latency for DMA cyclic clients Nandor Han
2016-08-08 12:38   ` [PATCH 2/4] dmaengine: imx-sdma - update the residue calculation for cyclic channels Nandor Han
2016-08-08 12:38   ` [PATCH 3/4] serial: imx-serial - update UART IMX driver to use cyclic DMA Nandor Han
2016-08-08 12:38   ` Nandor Han [this message]

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=1f338636da75ccdf330e3e1164a023219faa56e0.1470656658.git.nandor.han@ge.com \
    --to=nandor.han@ge.com \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=peter.senna@collabora.com \
    --cc=vinod.koul@intel.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).