From: Dave Martin <Dave.Martin@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: Andre Przywara <andre.przywara@arm.com>,
Stephen Boyd <sboyd@codeaurora.org>,
Russell King <linux@armlinux.org.uk>,
Andy Gross <andy.gross@linaro.org>,
linux-serial@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Bhupinder Thakur <bhupinder.thakur@linaro.org>
Subject: [RFC PATCH 3/3] tty: amba-pl011: earlycon: Don't drain the transmitter after each char
Date: Wed, 18 Oct 2017 15:14:48 +0100 [thread overview]
Message-ID: <1508336088-3948-4-git-send-email-Dave.Martin@arm.com> (raw)
In-Reply-To: <1508336088-3948-1-git-send-email-Dave.Martin@arm.com>
Currently, the pl011 earlycon implementation waits for the UART
transmitter to drain completely and become idle after each
character is written.
This can result in (mostly harmless) delays and stuttering output
on the wire, and can also lead to poor performance in virtualised
UART implementations: thrashing between VMs can occur as each
character gets forcibly drained to the remove sink (dom0 in the Xen
case) before the source guest writes another character.
However, the semantics of earlycon don't allow callers to write one
character at a time with the expectation of completion: the only
interface to exposed to earlycon writes a whole string before
returning.
So, this patch eliminates the draining of the transmitted from
pl011_putc() and moves if to the the and of pl011_early_write()
instead. From the earlycon caller's point of view, the effect
should be faster but otherwise identical: either way, all the
characters have gone out onto the wire before the write method
returns.
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
---
For background on the virtualisation issue, see [1]. Although
virtual UART implementations should be working around this issue
somehow for compatibility with current and older kernels, this patch
should promote better interoperation, and earlycon throughput should
improve a bit on real hardware too.
[1] Re: [Xen-devel] [PATCH 26/27 v12] arm/xen: vpl011: Fix the slow
early console SBSA UART output
https://lists.xenproject.org/archives/html/xen-devel/2017-10/msg01949.html
---
drivers/tty/serial/amba-pl011.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 084ed3f..e27059a 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2444,16 +2444,18 @@ static void pl011_putc(struct uart_port *port, int c)
while (__pl011_read(port, reg_offset, REG_FR) & UART01x_FR_TXFF)
cpu_relax();
__pl011_write(c, port, reg_offset, REG_DR);
- while (!__pl011_tx_empty(port, reg_offset, vendor))
- cpu_relax();
}
static void pl011_early_write(struct console *con, const char *s, unsigned n)
{
struct earlycon_device *dev = con->data;
+ const struct vendor_data *vendor = dev->port.private_data;
+ const u16 *reg_offset = vendor->reg_offset;
wmb();
uart_console_write(&dev->port, s, n, pl011_putc);
+ while (!__pl011_tx_empty(&dev->port, reg_offset, vendor))
+ cpu_relax();
}
static int __init
--
2.1.4
prev parent reply other threads:[~2017-10-18 14:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-18 14:14 [RFC PATCH 0/3] tty: amba-pl011: Decruft and streamline earlycon output Dave Martin
2017-10-18 14:14 ` [RFC PATCH 1/3] tty: amba-pl011: earlycon: Switch to relaxed I/O Dave Martin
2017-10-18 14:14 ` [RFC PATCH 2/3] tty: amba-pl011: earlycon: Unify earlycon backends Dave Martin
2017-10-18 14:14 ` Dave Martin [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=1508336088-3948-4-git-send-email-Dave.Martin@arm.com \
--to=dave.martin@arm.com \
--cc=andre.przywara@arm.com \
--cc=andy.gross@linaro.org \
--cc=bhupinder.thakur@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=sboyd@codeaurora.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 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).