From patchwork Wed Oct 18 14:14:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 10014807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3BE0E60215 for ; Wed, 18 Oct 2017 14:23:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F6F528DEB for ; Wed, 18 Oct 2017 14:23:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 243F128DEA; Wed, 18 Oct 2017 14:23:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8D71028DE1 for ; Wed, 18 Oct 2017 14:23:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=RvVn83LeL+JvzvFsQ4aG+alsknJBpPQ1md2YlAsTKFs=; b=NdDRm181eJIG2PF9JM0wEgoPIo 5y/u54R3MaGieNRy6okkP2zL8etsziMDvQNUj6HgNpCT8xeS+hkLFl5C65QQlBW0EfBL+Wc1NKYN5 c8HMT0palWNYGPLJcQreExnPj0Vzh9zm4wXia3Zph1G7zuU05oMZeSTkzUkXrhrbr15azjX2Nm018 Vo5076iV2feMz0v2ZCXZ70pAFHASG3wooKAH/3oOgebH8G2B/GWqEAtKGu3SoLk6NRynRhIr72rCv mwY0e02UiHCbmJBUOYuCsbkf3X0xhqp/7x/GkB6MYr9nmQRxq5WcwpKsLaPB9vrx1MMeVnnxTcHe3 PEGoxyEw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e4pFN-0004QM-8T; Wed, 18 Oct 2017 14:23:01 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e4p7r-00060W-6x for linux-arm-kernel@lists.infradead.org; Wed, 18 Oct 2017 14:15:23 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 715261610; Wed, 18 Oct 2017 07:14:59 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1B6C53F483; Wed, 18 Oct 2017 07:14:57 -0700 (PDT) From: Dave Martin To: linux-arm-kernel@lists.infradead.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 Message-Id: <1508336088-3948-4-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1508336088-3948-1-git-send-email-Dave.Martin@arm.com> References: <1508336088-3948-1-git-send-email-Dave.Martin@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171018_071515_376520_E073CCC2 X-CRM114-Status: GOOD ( 11.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andre Przywara , Stephen Boyd , Russell King , Andy Gross , linux-serial@vger.kernel.org, Greg Kroah-Hartman , Bhupinder Thakur MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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