Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / Atom feed
From: bigeasy@linutronix.de (Sebastian Andrzej Siewior)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 09/16] tty: serial: 8250_dma: Add a TX trigger workaround for AM33xx
Date: Thu, 2 Oct 2014 12:27:23 +0200
Message-ID: <20141002102723.GB23661@linutronix.de> (raw)
In-Reply-To: <20140930084416.GB31111@ci00147.xsens-tech.local>

* Frans Klaver | 2014-09-30 10:44:16 [+0200]:

>On Mon, Sep 29, 2014 at 12:30:43PM +0200, Frans Klaver wrote:
>> On Mon, Sep 29, 2014 at 11:54:40AM +0200, Sebastian Andrzej Siewior wrote:
>> > For your "too much work for irq" problem: Could you add trace_printk()
>> > in tx/rx dma start/complete, and irq routine? The interresting part is
>> > what is the irq routine doing once entered. It might be a condition that
>> > is ignored at first and "acked" later while serving another event. Or it
>> > is really doing something and this is more or less "legal".
>> 
>
>Here's some trace output I get. I hope branches become clear by the
>calls they do.
>
>       uart_test-482   [000] .ns.    17.860139: __dma_rx_do_complete: error: 0, uart_bug_dma: 32
>       uart_test-482   [000] .ns.    17.860141: __dma_rx_do_complete: rx_dma(p, 0)

these two happen outside the IRQ routine for every 48 bytes.
?
>       uart_test-483   [000] dnh.    17.861018: serial8250_interrupt: irq 89
>       uart_test-483   [000] dnh.    17.861026: serial8250_interrupt: 89 e
e? Did was the routine invoked 0xe times or this a register?

>       uart_test-483   [000] .ns.    17.861045: __dma_rx_do_complete: error: 0, uart_bug_dma: 32
>       uart_test-483   [000] .ns.    17.861047: __dma_rx_do_complete: rx_dma(p, 0)
another 48bytes

>       uart_test-479   [000] d.H.    17.861124: serial8250_interrupt: irq 89
>       uart_test-479   [000] d.H.    17.861133: serial8250_handle_irq: l1 IIR cc LSR 61
>       uart_test-479   [000] d.H.    17.861135: serial8250_handle_irq: rx_dma(up, iir)
>       uart_test-479   [000] d.H.    17.861139: serial8250_rx_dma: l1, UART_IIR_RX_TIMEOUT
>       uart_test-479   [000] d.H.    17.861147: __dma_rx_do_complete: error: 1, uart_bug_dma: 32
>       uart_test-479   [000] d.H.    17.861150: serial8250_handle_irq: rx_chars(up, status)
>       uart_test-479   [000] d.H.    17.861190: serial8250_handle_irq: rx_dma(up, 0)
timeout, manual purge. Do you have an idea how many bytes were manually
received?

>       uart_test-479   [000] d.H.    17.861205: serial8250_interrupt: 89 e
>     kworker/0:1-10    [000] dnH.    17.864949: serial8250_interrupt: irq 89
>
>So far so good. We're just entered interrupt where stuff goes awry. The
>following pattern repeats over 600 times:
>
>     kworker/0:1-10    [000] dnH.    17.865198: serial8250_handle_irq: l1 IIR cc LSR 61
>     kworker/0:1-10    [000] dnH.    17.865254: serial8250_handle_irq: rx_dma(up, iir)
>     kworker/0:1-10    [000] dnH.    17.865333: serial8250_rx_dma: l1, UART_IIR_RX_TIMEOUT
>     kworker/0:1-10    [000] dnH.    17.865626: __dma_rx_do_complete: error: 1, uart_bug_dma: 32
>     kworker/0:1-10    [000] dnH.    17.865747: serial8250_handle_irq: rx_chars(up, status)
>     kworker/0:1-10    [000] dnH.    17.868797: serial8250_handle_irq: rx_dma(up, 0)
>
>ending with:
>
>     kworker/0:1-10    [000] dnH.    20.027093: serial8250_interrupt: serial8250: too much work for irq89
>     kworker/0:1-10    [000] dnH.    20.027181: serial8250_interrupt: 89 e
>
>This clogs the entire system until I disconnect the communication lines.
>
>So we get an RX timeout. The receiver fifo trigger level was not reached
>and 8250_core is left to copy the remaining data. I would expect that if
>the trigger level wasn't reached, we wouldn't need to be doing this that
>often. On the other hand, could we be trapped reading data from rx
>without dma helping us? And how could we resolve this?

So if I understand you correct, then you enter serial8250_interrupt()
and then you enter multiple times omap_8250_dma_handle_irq() and
you always get a TIMEOUT event and fetch byte(s) manualy via
serial8250_rx_chars(). And after one iteration UART_IIR_NO_INT is not
set and you do it again, right?

I have no idea when exactly the timeout-interrupt fires. The manual
says: "? the count is reset when there is activity on uarti_rx ?" but it
does not say how often it increments before the level is reached.
It also might be that you have a small gap between two bytes and this
high baud rate the gap is considered as a timeout event.

Another thing could be that if the we enqueue a RX transfer from the
dma_completion callback then we have too many bytes in the FIFO already
becahse the callback is invoked from softirq. What happens if we cut the
middle man via


diff --git a/drivers/dma/virt-dma.c b/drivers/dma/virt-dma.c
index 6f80432..21b04bd 100644
--- a/drivers/dma/virt-dma.c
+++ b/drivers/dma/virt-dma.c
@@ -63,8 +63,9 @@ static void vchan_complete(unsigned long arg)
 	dma_async_tx_callback cb = NULL;
 	void *cb_data = NULL;
 	LIST_HEAD(head);
+	unsigned long flags;
 
-	spin_lock_irq(&vc->lock);
+	spin_lock_irqsave(&vc->lock, flags);
 	list_splice_tail_init(&vc->desc_completed, &head);
 	vd = vc->cyclic;
 	if (vd) {
@@ -72,7 +73,7 @@ static void vchan_complete(unsigned long arg)
 		cb = vd->tx.callback;
 		cb_data = vd->tx.callback_param;
 	}
-	spin_unlock_irq(&vc->lock);
+	spin_unlock_irqrestore(&vc->lock, flags);
 
 	if (cb)
 		cb(cb_data);
diff --git a/drivers/dma/virt-dma.h b/drivers/dma/virt-dma.h
index 181b952..7632338 100644
--- a/drivers/dma/virt-dma.h
+++ b/drivers/dma/virt-dma.h
@@ -92,7 +92,10 @@ static inline void vchan_cookie_complete(struct virt_dma_desc *vd)
 		 vd, cookie);
 	list_add_tail(&vd->node, &vc->desc_completed);
 
-	tasklet_schedule(&vc->task);
+	if (vd->tx.my_uart)
+		vc->task.func(vc);
+	else
+		tasklet_schedule(&vc->task);
 }
 
 /**
diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index 57a8b12..5d7ee92 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -728,6 +728,7 @@ static int omap_8250_rx_dma(struct uart_8250_port *p, unsigned int iir)
 	dma->rx_running = 1;
 	desc->callback = __dma_rx_complete;
 	desc->callback_param = p;
+	desc->my_uart = 1;
 
 	dma->rx_cookie = dmaengine_submit(desc);
 
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 1f9e642..0f5fbe1 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -459,6 +459,7 @@ struct dmaengine_unmap_data {
 struct dma_async_tx_descriptor {
 	dma_cookie_t cookie;
 	enum dma_ctrl_flags flags; /* not a 'long' to pack with cookie */
+	u32 my_uart;
 	dma_addr_t phys;
 	struct dma_chan *chan;
 	dma_cookie_t (*tx_submit)(struct dma_async_tx_descriptor *tx);

>
>Frans

Sebastian

  reply index

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-10 19:29 [PATCH 00/16 v9] omap 8250 based uart + DMA Sebastian Andrzej Siewior
2014-09-10 19:29 ` [PATCH 01/16] tty: serial: 8250_core: allow to set ->throttle / ->unthrottle callbacks Sebastian Andrzej Siewior
2014-09-10 19:29 ` [PATCH 02/16] tty: serial: 8250_core: add run time pm Sebastian Andrzej Siewior
2014-09-29  9:46   ` Frans Klaver
2014-09-29 13:39     ` Sebastian Andrzej Siewior
2014-09-10 19:29 ` [PATCH 03/16] tty: serial: 8250_core: read only RX if there is something in the FIFO Sebastian Andrzej Siewior
2015-02-09 13:34   ` Nicolas Schichan
2015-02-09 23:34     ` Peter Hurley
2015-02-10  9:32       ` Sebastian Andrzej Siewior
2015-02-10 12:04       ` Nicolas Schichan
2015-02-10 17:46         ` Peter Hurley
2015-02-11 20:01           ` Peter Hurley
2015-02-11 20:03             ` Tony Lindgren
2015-02-11 20:42               ` Peter Hurley
2015-02-12  8:45                 ` Sebastian Andrzej Siewior
2015-02-12  9:40                   ` Russell King - ARM Linux
2015-02-12 16:32                   ` Peter Hurley
2015-02-12 19:23                     ` Sebastian Andrzej Siewior
2015-02-12 19:55                       ` Peter Hurley
2015-02-12 20:34                         ` Sebastian Andrzej Siewior
2015-02-13 18:51                         ` Sebastian Andrzej Siewior
2015-02-13 23:15                           ` Russell King - ARM Linux
2015-02-15 17:32                             ` [PATCH] serial: 8250: Revert "tty: serial: 8250_core: read only RX if there is something in the FIFO" Sebastian Andrzej Siewior
2015-05-12 20:25                               ` Tony Lindgren
2014-09-10 19:29 ` [PATCH 04/16] tty: serial: 8250_core: use the ->line argument as a hint in serial8250_find_match_or_unused() Sebastian Andrzej Siewior
2014-09-10 19:30 ` [PATCH 05/16] tty: serial: 8250_core: remove UART_IER_RDI in serial8250_stop_rx() Sebastian Andrzej Siewior
2014-09-11 11:19   ` Heikki Krogerus
2014-09-10 19:30 ` [PATCH 06/16] tty: serial: Add 8250-core based omap driver Sebastian Andrzej Siewior
2014-09-11 11:57   ` Peter Hurley
2014-09-16 17:01     ` Sebastian Andrzej Siewior
2014-09-29  9:38   ` Frans Klaver
2014-09-29 13:27     ` Sebastian Andrzej Siewior
2014-09-29 13:34       ` Frans Klaver
2014-09-10 19:30 ` [PATCH 07/16] tty: serial: 8250_dma: handle error on TX submit Sebastian Andrzej Siewior
2014-09-10 19:30 ` [PATCH 08/16] tty: serial: 8250_dma: enqueue RX dma again on completion Sebastian Andrzej Siewior
2014-09-10 19:30 ` [PATCH 09/16] tty: serial: 8250_dma: Add a TX trigger workaround for AM33xx Sebastian Andrzej Siewior
2014-09-11 11:17   ` Heikki Krogerus
2014-09-11 11:42     ` Sebastian Andrzej Siewior
2014-09-11 12:32       ` Peter Hurley
2014-09-11 12:50         ` Sebastian Andrzej Siewior
2014-09-11 14:35           ` Peter Hurley
2014-09-15 17:01             ` Sebastian Andrzej Siewior
2014-09-16 16:55               ` Sebastian Andrzej Siewior
2014-09-17 12:20                 ` Peter Hurley
2014-09-17 16:25                   ` Sebastian Andrzej Siewior
2014-09-29 16:15                   ` Sebastian Andrzej Siewior
2014-09-11 15:11           ` Frans Klaver
2014-09-11 16:04             ` Sebastian Andrzej Siewior
2014-09-11 17:04               ` Frans Klaver
2014-09-12  7:23                 ` Sebastian Andrzej Siewior
     [not found]                   ` <20140912094010.GE28458@ci00147.xsens-tech.local>
2014-09-12  9:51                     ` Sebastian Andrzej Siewior
2014-09-12 10:28                       ` Frans Klaver
2014-09-15 16:42                         ` Sebastian Andrzej Siewior
2014-09-16  9:05                           ` Frans Klaver
2014-09-16 12:42                             ` Frans Klaver
2014-09-16 14:23                               ` Frans Klaver
2014-09-17 10:28                           ` Frans Klaver
2014-09-21 20:41                             ` Sebastian Andrzej Siewior
2014-09-22  9:28                               ` Frans Klaver
2014-09-24  7:56                                 ` Sebastian Andrzej Siewior
2014-09-25 15:14                                 ` Sebastian Andrzej Siewior
2014-09-25 15:18                                   ` Frans Klaver
2014-09-29  8:50                                   ` Frans Klaver
2014-09-29  9:54                                     ` Sebastian Andrzej Siewior
2014-09-29 10:30                                       ` Frans Klaver
2014-09-30  8:44                                         ` Frans Klaver
2014-10-02 10:27                                           ` Sebastian Andrzej Siewior [this message]
2014-10-13 14:55                                             ` Frans Klaver
2014-09-23 17:03                               ` Peter Hurley
2014-09-24  7:53                                 ` Sebastian Andrzej Siewior
2014-09-25 10:42                                   ` Sebastian Andrzej Siewior
2014-09-25 11:31                                     ` Peter Hurley
2014-09-25 13:11                                       ` Sebastian Andrzej Siewior
2014-09-17 16:34       ` Sebastian Andrzej Siewior
2014-09-19 10:22         ` Heikki Krogerus
2014-09-19 10:58           ` Sebastian Andrzej Siewior
2014-09-19 11:25             ` Peter Hurley
2014-09-22  7:46             ` Heikki Krogerus
2014-09-25  9:24               ` Sebastian Andrzej Siewior
2014-09-10 19:30 ` [PATCH 10/16] tty: serial: 8250_dma: optimize the xmit path due to UART_BUG_DMA_TX Sebastian Andrzej Siewior
2014-09-10 19:30 ` [PATCH 11/16] tty: serial: 8250_dma: keep own book keeping about RX transfers Sebastian Andrzej Siewior
2014-09-10 19:30 ` [PATCH 12/16] tty: serial: 8250_dma: handle the UART RDI event while DMA remains idle Sebastian Andrzej Siewior
2014-09-29  9:23   ` Frans Klaver
2014-09-10 19:30 ` [PATCH 13/16] tty: serial: 8250_dma: add pm runtime Sebastian Andrzej Siewior
2014-09-29  9:26   ` Frans Klaver
2014-09-29  9:56     ` Sebastian Andrzej Siewior
2014-09-10 19:30 ` [PATCH 14/16] arm: dts: am33xx: add DMA properties for UART Sebastian Andrzej Siewior
2014-09-10 19:30 ` [PATCH 15/16] arm: dts: dra7: " Sebastian Andrzej Siewior
2014-09-10 19:30 ` [PATCH 16/16] tty: serial: 8250: omap: add dma support Sebastian Andrzej Siewior
2014-09-12 22:43 ` [PATCH 00/16 v9] omap 8250 based uart + DMA Tony Lindgren
2014-09-15 11:50   ` Sebastian Andrzej Siewior
2014-09-16 12:57     ` Sebastian Andrzej Siewior
2014-09-16 16:48       ` Tony Lindgren
2014-09-16 21:30         ` Tony Lindgren
2014-09-17  8:38           ` Sebastian Andrzej Siewior
2014-09-17  9:05 ` Sebastian Andrzej Siewior
2014-09-26 16:02   ` Greg KH

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=20141002102723.GB23661@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org
	public-inbox-index linux-arm-kernel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git