linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: linux-serial@vger.kernel.org
Cc: tony@atomide.com, gregkh@linuxfoundation.org,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	linux-kernel@vger.kernel.org, balbi@ti.com, vinod.koul@intel.com,
	linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH 05/13] tty: serial: 8250_dma: keep own book keeping about RX transfers
Date: Mon, 29 Sep 2014 20:06:41 +0200	[thread overview]
Message-ID: <1412014009-13315-6-git-send-email-bigeasy@linutronix.de> (raw)
In-Reply-To: <1412014009-13315-1-git-send-email-bigeasy@linutronix.de>

After dmaengine_terminate_all() has been invoked then both DMA drivers
(edma and omap-dma) do not invoke dma_cookie_complete() to mark the
transfer as complete. This dma_cookie_complete() is performed by the
Synopsys DesignWare driver which is probably the only one that is used
by omap8250-dma and hence don't see following problem…
…which is that once a RX transfer has been terminated then following
query of channel status reports DMA_IN_PROGRESS (again: the actual
transfer has been canceled, there is nothing going on anymore).

This means that serial8250_rx_dma() never enqueues another DMA transfer
because it (wrongly) assumes that there is a transer already pending.

Vinod Koul refuses to accept a patch which adds this
dma_cookie_complete() to both drivers and so dmaengine_tx_status() would
report DMA_COMPLETE instead (and behave like the Synopsys DesignWare
driver already does). He argues that I am not allowed to use the cookie
to query the status and that the driver already cleaned everything up after
the invokation of dmaengine_terminate_all().

To end this I add a bookkeeping whether or not a RX-transfer has been
started to the 8250-dma code. It has already been done for the TX side.
*Now* we learn about the RX status based on our bookkeeping and don't
need dmaengine_tx_status() for this anymore.

Cc: vinod.koul@intel.com
Reviewed-by: Tony Lindgren <tony@atomide.com>
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/tty/serial/8250/8250.h     |  1 +
 drivers/tty/serial/8250/8250_dma.c | 10 ++++------
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
index a63d198f8d03..ebab625179d4 100644
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
@@ -42,6 +42,7 @@ struct uart_8250_dma {
 
 	unsigned char		tx_running:1;
 	unsigned char		tx_err: 1;
+	unsigned char		rx_running:1;
 };
 
 struct old_serial_port {
diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c
index 69e54abb6e71..db9eda3c12d6 100644
--- a/drivers/tty/serial/8250/8250_dma.c
+++ b/drivers/tty/serial/8250/8250_dma.c
@@ -61,6 +61,7 @@ static void __dma_rx_complete(void *param)
 	dma_sync_single_for_cpu(dma->rxchan->device->dev, dma->rx_addr,
 				dma->rx_size, DMA_FROM_DEVICE);
 
+	dma->rx_running = 0;
 	dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state);
 	dmaengine_terminate_all(dma->rxchan);
 
@@ -123,10 +124,6 @@ int serial8250_rx_dma(struct uart_8250_port *p, unsigned int iir)
 {
 	struct uart_8250_dma		*dma = p->dma;
 	struct dma_async_tx_descriptor	*desc;
-	struct dma_tx_state		state;
-	int				dma_status;
-
-	dma_status = dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state);
 
 	switch (iir & 0x3f) {
 	case UART_IIR_RLSI:
@@ -137,7 +134,7 @@ int serial8250_rx_dma(struct uart_8250_port *p, unsigned int iir)
 		 * If RCVR FIFO trigger level was not reached, complete the
 		 * transfer and let 8250_core copy the remaining data.
 		 */
-		if (dma_status == DMA_IN_PROGRESS) {
+		if (dma->rx_running) {
 			dmaengine_pause(dma->rxchan);
 			__dma_rx_complete(p);
 		}
@@ -146,7 +143,7 @@ int serial8250_rx_dma(struct uart_8250_port *p, unsigned int iir)
 		break;
 	}
 
-	if (dma_status)
+	if (dma->rx_running)
 		return 0;
 
 	desc = dmaengine_prep_slave_single(dma->rxchan, dma->rx_addr,
@@ -155,6 +152,7 @@ int serial8250_rx_dma(struct uart_8250_port *p, unsigned int iir)
 	if (!desc)
 		return -EBUSY;
 
+	dma->rx_running = 1;
 	desc->callback = __dma_rx_complete;
 	desc->callback_param = p;
 
-- 
2.1.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2014-09-29 18:06 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-29 18:06 [PATCH 00/13 v10] omap 8250 based UART + DMA Sebastian Andrzej Siewior
2014-09-29 18:06 ` [PATCH 01/13] tty: serial: 8250: Fix wording in runtime-PM comments Sebastian Andrzej Siewior
2014-09-29 18:06 ` [PATCH 02/13] tty: serial: 8250: make serial8250_console_setup() non _init Sebastian Andrzej Siewior
2014-09-30 20:27   ` Peter Hurley
2014-09-29 18:06 ` [PATCH 03/13] tty: serial: Add 8250-core based omap driver Sebastian Andrzej Siewior
2014-09-29 18:06 ` [PATCH 04/13] tty: serial: 8250_dma: handle error on TX submit Sebastian Andrzej Siewior
2014-09-29 18:06 ` Sebastian Andrzej Siewior [this message]
2014-09-29 18:06 ` [PATCH 06/13] tty: serial: 8250: allow to use custom DMA implementation Sebastian Andrzej Siewior
2014-09-29 18:06 ` [PATCH 07/13] tty: serial: 8250_omap: add custom DMA-TX callback Sebastian Andrzej Siewior
2014-09-29 18:06 ` [PATCH 08/13] tty: serial: 8250_omap: add custom DMA-RX callback Sebastian Andrzej Siewior
2014-09-29 18:06 ` [PATCH 09/13] dmaengine: edma: check for echan->edesc => NULL in edma_dma_pause() Sebastian Andrzej Siewior
2014-10-01 12:00   ` Peter Ujfalusi
2014-10-15 15:27   ` Vinod Koul
2014-10-15 15:28   ` Vinod Koul
2014-09-29 18:06 ` [PATCH 10/13] arm: dts: am33xx: add DMA properties for UART Sebastian Andrzej Siewior
2014-09-29 18:06 ` [PATCH 11/13] arm: dts: dra7: " Sebastian Andrzej Siewior
2014-11-04 17:02   ` Lennart Sorensen
2014-11-04 17:06     ` Sebastian Andrzej Siewior
2014-11-04 17:21       ` Lennart Sorensen
2014-11-04 18:32         ` Javier Martinez Canillas
2014-11-04 18:48           ` Nishanth Menon
     [not found]           ` <CABxcv=kT+M70Xoyf_z4eQQyM0Oo9S5Y0YeX2R6PbAqxK-JTLLg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-04 19:00             ` Lennart Sorensen
2014-11-04 18:33         ` Lennart Sorensen
2014-11-04 21:03           ` Lennart Sorensen
     [not found]             ` <20141104210315.GF24112-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys@public.gmane.org>
2014-11-05  1:15               ` Lennart Sorensen
     [not found]                 ` <20141105011506.GG24112-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys@public.gmane.org>
2014-11-05  8:11                   ` Sebastian Andrzej Siewior
2014-11-05 15:33                     ` Lennart Sorensen
2014-11-05 16:20                       ` Lennart Sorensen
2014-11-05 16:30                         ` Sebastian Andrzej Siewior
2014-11-05 19:43                           ` Lennart Sorensen
     [not found]                             ` <20141105194323.GI24112-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys@public.gmane.org>
2014-11-13 18:34                               ` Sebastian Andrzej Siewior
2014-11-13 22:08                                 ` Lennart Sorensen
2014-09-29 18:06 ` [PATCH 12/13] tty: serial: 8250: omap: add custom irq handling Sebastian Andrzej Siewior
2014-10-09 13:19   ` Heikki Krogerus
2014-09-29 18:06 ` [PATCH 13/13] tty: serial: 8250: omap: add dma support Sebastian Andrzej Siewior
2014-10-02 16:43 ` [PATCH 00/13 v10] omap 8250 based UART + DMA Tony Lindgren
2014-10-02 23:19   ` Sebastian Andrzej Siewior
2014-10-03 13:08 ` Peter Hurley
2014-11-06  3:14 ` Greg KH
2014-11-06 10:27   ` Sebastian Andrzej Siewior
2014-11-10 17:24     ` Tony Lindgren

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=1412014009-13315-6-git-send-email-bigeasy@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=balbi@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=tony@atomide.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).