All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bhupinder Thakur <bhupinder.thakur@linaro.org>
To: xen-devel@lists.xenproject.org
Cc: Andre Przywara <andre.przywara@arm.com>,
	Julien Grall <julien.grall@arm.com>,
	Stefano Stabellini <sstabellini@kernel.org>
Subject: [PATCH 26/27 v8] xen/arm: vpl011: Correct the logic for asserting/de-asserting SBSA UART TX interrupt
Date: Mon, 28 Aug 2017 14:26:09 +0530	[thread overview]
Message-ID: <1503910570-24427-27-git-send-email-bhupinder.thakur@linaro.org> (raw)
In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org>

This patch fixes the issue observed when pl011 patches were tested on
the junos hardware by Andre/Julien. It was observed that when large output is
generated such as on running 'find /', output was getting truncated intermittently
due to OUT ring buffer getting full.

This issue was due to the fact that the SBSA UART driver expects that when
a TX interrupt is asserted then the FIFO queue should be atleast half empty and
that it can write N bytes in the FIFO, where N is half the FIFO queue size, without
the bytes getting dropped due to FIFO getting full.

This requirement is as per section 3.4.2 of [1], which is:

-------------------------------------------------------------------------------
UARTTXINTR

If the FIFOs are enabled and the transmit FIFO reaches the programmed
trigger level. When this happens, the transmit interrupt is asserted HIGH. The
transmit interrupt is cleared by writing data to the transmit FIFO until it
becomes greater than the trigger level, or by clearing the interrupt.
-------------------------------------------------------------------------------

The SBSA UART fifo size is 32 bytes and so it expects that space for 16 bytes
should be available when TX interrupt is asserted.

The pl011 emulation logic was asserting the TX interrupt as soon as
any space became available in the FIFO and the SBSA UART driver tried to write
more data (upto 16 bytes) in the FIFO expecting that there is enough space
available.

The fix was to ensure that the TX interriupt is raised only when there
is space available for 16 bytes or more in the FIFO.

[1] http://infocenter.arm.com/help/topic/com.arm.doc.ddi0183f/DDI0183.pdf

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
CC: Julien Grall <julien.grall@arm.com>
CC: Andre Przywara <andre.przywara@arm.com>
CC: Stefano Stabellini <sstabellini@kernel.org>

 xen/arch/arm/vpl011.c | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c
index 56d9cbe..1e72fca 100644
--- a/xen/arch/arm/vpl011.c
+++ b/xen/arch/arm/vpl011.c
@@ -152,12 +152,20 @@ static void vpl011_write_data(struct domain *d, uint8_t data)
     else
         gprintk(XENLOG_ERR, "vpl011: Unexpected OUT ring buffer full\n");
 
-    if ( xencons_queued(out_prod, out_cons, sizeof(intf->out)) ==
-         sizeof (intf->out) )
-    {
-        vpl011->uartfr |= TXFF;
+    /*
+     * Ensure that there is space for atleast 16 bytes before asserting the
+     * TXI interrupt status bit because the SBSA UART driver may write
+     * 16 bytes (i.e. half the SBSA UART fifo size of 32) on getting
+     * a TX interrupt.
+     */
+    if ( xencons_queued(out_prod, out_cons, sizeof(intf->out)) <=
+         (sizeof (intf->out) - 16) )
+        vpl011->uartris |= TXI;
+    else if ( xencons_queued(out_prod, out_cons, sizeof(intf->out)) !=
+              sizeof (intf->out) )
         vpl011->uartris &= ~TXI;
-    }
+    else
+        vpl011->uartfr |= TXFF;
 
     vpl011->uartfr |= BUSY;
 
@@ -368,7 +376,16 @@ static void vpl011_data_avail(struct domain *d)
     if ( out_ring_qsize != sizeof(intf->out) )
     {
         vpl011->uartfr &= ~TXFF;
-        vpl011->uartris |= TXI;
+
+        /*
+         * Ensure that there is space for atleast 16 bytes before asserting the
+         * TXI interrupt status bit because the SBSA UART driver may write upto
+         * 16 bytes (i.e. half the SBSA UART fifo size of 32) on getting
+         * a TX interrupt.
+         */
+        if ( out_ring_qsize <= (sizeof(intf->out) - 16) )
+            vpl011->uartris |= TXI;
+
         if ( out_ring_qsize == 0 )
         {
             vpl011->uartfr &= ~BUSY;
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-08-28  8:57 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28  8:55 [PATCH 00/27 v8] SBSA UART emulation support in Xen Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 01/27 v8] xen/arm: vpl011: Define common ring buffer helper functions in console.h Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 02/27 v8] xen/arm: vpl011: Add SBSA UART emulation in Xen Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 03/27 v8] xen/arm: vpl011: Allocate a new GFN in the toolstack for vuart Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 04/27 v8] xen/arm: vpl011: Add support for vuart in libxl Bhupinder Thakur
2017-09-07 10:54   ` Andre Przywara
2017-08-28  8:55 ` [PATCH 05/27 v8] xen/arm: vpl011: Rearrange xen header includes in alphabetical order in domctl.c Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 06/27 v8] xen/arm: vpl011: Add a new domctl API to initialize vpl011 Bhupinder Thakur
2017-08-28  9:09   ` Jan Beulich
2017-09-14  6:46     ` Bhupinder Thakur
2017-08-28 16:39   ` Wei Liu
2017-08-28 16:52   ` Wei Liu
2017-08-28  8:55 ` [PATCH 07/27 v8] xen/arm: vpl011: Add a new vuart node in the xenstore Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 08/27 v8] xen/arm: vpl011: Modify xenconsole to define and use a new console structure Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 09/27 v8] xen/arm: vpl011: Rename the console structure field conspath to xspath Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 10/27 v8] xen/arm: vpl011: Modify xenconsole functions to take console structure as input Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 11/27 v8] xen/arm: vpl011: Add a new console_init function in xenconsole Bhupinder Thakur
2017-08-28 16:40   ` Wei Liu
2017-08-28  8:55 ` [PATCH 12/27 v8] xen/arm: vpl011: Add a new buffer_available " Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 13/27 v8] xen/arm: vpl011: Add a new maybe_add_console_evtchn_fd " Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 14/27 v8] xen/arm: vpl011: Add a new maybe_add_console_tty_fd " Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 15/27 v8] xen/arm: vpl011: Add a new console_evtchn_unmask " Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 16/27 v8] xen/arm: vpl011: Add a new handle_console_ring " Bhupinder Thakur
2017-08-28  8:56 ` [PATCH 17/27 v8] xen/arm: vpl011: Add a new handle_console_tty " Bhupinder Thakur
2017-08-28  8:56 ` [PATCH 18/27 v8] xen/arm: vpl011: Add a new console_cleanup " Bhupinder Thakur
2017-08-28  8:56 ` [PATCH 19/27 v8] xen/arm: vpl011: Add a new console_open_log " Bhupinder Thakur
2017-08-28  8:56 ` [PATCH 20/27 v8] xen/arm: vpl011: Add a new console_close_evtchn " Bhupinder Thakur
2017-08-28  8:56 ` [PATCH 21/27 v8] xen/arm: vpl011: Add support for multiple consoles " Bhupinder Thakur
2017-08-28 16:50   ` Wei Liu
2017-08-28  8:56 ` [PATCH 22/27 v8] xen/arm: vpl011: Add support for vuart console " Bhupinder Thakur
2017-08-28  9:11   ` Jan Beulich
2017-09-04 16:28     ` Bhupinder Thakur
2017-09-05  5:29       ` Jan Beulich
2017-09-05  9:31       ` Wei Liu
2017-09-06 17:29         ` Bhupinder Thakur
2017-09-07  9:08           ` Wei Liu
2017-09-12  7:25             ` Bhupinder Thakur
2017-09-12  8:54               ` Wei Liu
2017-08-28  8:56 ` [PATCH 23/27 v8] xen/arm: vpl011: Add a new vuart console type to xenconsole client Bhupinder Thakur
2017-08-28  8:56 ` [PATCH 24/27 v8] xen/arm: vpl011: Add a pl011 uart DT node in the guest device tree Bhupinder Thakur
2017-08-28  8:56 ` [PATCH 25/27 v8] xen/arm: vpl011: Update documentation for vuart console support Bhupinder Thakur
2017-08-28  8:56 ` Bhupinder Thakur [this message]
2017-09-07 14:37   ` [PATCH 26/27 v8] xen/arm: vpl011: Correct the logic for asserting/de-asserting SBSA UART TX interrupt Andre Przywara
2017-09-11 16:39     ` Bhupinder Thakur
2017-09-12 14:35     ` Julien Grall
2017-09-12 14:58   ` Julien Grall
2017-08-28  8:56 ` [PATCH 27/27 v8] xen/arm: vpl011: Fix the slow early console SBSA UART output Bhupinder Thakur

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=1503910570-24427-27-git-send-email-bhupinder.thakur@linaro.org \
    --to=bhupinder.thakur@linaro.org \
    --cc=andre.przywara@arm.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.