From nobody Thu Dec 26 14:32:36 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1502885451191525.218538536792; Wed, 16 Aug 2017 05:10:51 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A025621E14555; Wed, 16 Aug 2017 05:08:22 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E3BE921E2DA64 for ; Wed, 16 Aug 2017 05:08:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6555FD9620; Wed, 16 Aug 2017 12:10:46 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-59.phx2.redhat.com [10.3.116.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0ECB66EE5A; Wed, 16 Aug 2017 12:10:44 +0000 (UTC) X-Original-To: edk2-devel@lists.01.org DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6555FD9620 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=lersek@redhat.com From: Laszlo Ersek To: edk2-devel-01 Date: Wed, 16 Aug 2017 14:10:40 +0200 Message-Id: <20170816121040.15757-2-lersek@redhat.com> In-Reply-To: <20170816121040.15757-1-lersek@redhat.com> References: <20170816121040.15757-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 16 Aug 2017 12:10:46 +0000 (UTC) Subject: [edk2] [PATCH 1/1] ArmVirtPkg/FdtPL011SerialPortLib: call PL011UartLib in all SerialPortLib APIs X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heyi Guo , Star Zeng , Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" With the SerialDxe change in commit 4cf3f37c87ba ("MdeModulePkg SerialDxe: Process timeout consistently in SerialRead", 2017-07-18), setting EFI_SERIAL_INPUT_BUFFER_EMPTY in the "Control" output parameter, in the GetControl() SerialPortLib function, is no longer a "small optimization". Namely, due to the SerialDxe change, the GetOneKeyFromSerial() call in TerminalDxe's TerminalConInTimerHandler() can take very long if the input queue is empty, even if GetOneKeyFromSerial()'s return value causes the loop to be exited right after, in the first iteration. This issue causes a boot hang in ArmVirtQemu: with the input queue empty, TerminalConInTimerHandler() takes so long to return that, by the time it returns, there's another execution queued already (due to the associated timer event being signaled meanwhile). The boot process is stuck in the timer event handler. Therefore even the first GetOneKeyFromSerial() iteration must be prevented in TerminalConInTimerHandler() if the input queue is empty, and that requires implementing GetControl() for real. Implement the SetAttributes(), SetControl() and GetControl() APIs (of SerialPortExtLib origin) in FdtPL011SerialPortLib with calls to matching PL011UartLib functions. This follows the example of "ArmPlatformPkg/Library/PL011SerialPortLib" and also matches Star's original idea under [1]. The patch can be considered a continuation of commit ad7f6bc2e116 ("ArmVirtPkg: Use SerialDxe in MdeModulePkg instead of EmbeddedPkg", 2015-11-26), based on the mailing list threads [1] [2] [3]. [1] http://mid.mail-archive.com/1447752930-32880-12-git-send-email-star.zen= g@intel.com [2] http://mid.mail-archive.com/1448243067-1880-12-git-send-email-star.zeng= @intel.com [3] http://mid.mail-archive.com/b748580c-cb51-32c9-acf9-780841ef15da@redhat= .com Cc: Ard Biesheuvel Cc: Brijesh Singh Cc: Heyi Guo Cc: Star Zeng Originally-suggested-by: Star Zeng Reported-by: Brijesh Singh Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek Reviewed-by: Ard Biesheuvel Reviewed-by: Star Zeng Tested-by: Brijesh Singh --- ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c | 38 ++++= ++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib= .c b/ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c index 48a0530dcc2f..05d3547fda91 100644 --- a/ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c +++ b/ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c @@ -200,7 +200,23 @@ SerialPortSetAttributes ( IN OUT EFI_STOP_BITS_TYPE *StopBits ) { - return RETURN_UNSUPPORTED; + RETURN_STATUS Status; + + if (mSerialBaseAddress =3D=3D 0) { + Status =3D RETURN_UNSUPPORTED; + } else { + Status =3D PL011UartInitializePort ( + mSerialBaseAddress, + FixedPcdGet32 (PL011UartClkInHz), + BaudRate, + ReceiveFifoDepth, + Parity, + DataBits, + StopBits + ); + } + + return Status; } =20 /** @@ -219,7 +235,15 @@ SerialPortSetControl ( IN UINT32 Control ) { - return RETURN_UNSUPPORTED; + RETURN_STATUS Status; + + if (mSerialBaseAddress =3D=3D 0) { + Status =3D RETURN_UNSUPPORTED; + } else { + Status =3D PL011UartSetControl (mSerialBaseAddress, Control); + } + + return Status; } =20 /** @@ -238,6 +262,14 @@ SerialPortGetControl ( OUT UINT32 *Control ) { - return RETURN_UNSUPPORTED; + RETURN_STATUS Status; + + if (mSerialBaseAddress =3D=3D 0) { + Status =3D RETURN_UNSUPPORTED; + } else { + Status =3D PL011UartGetControl (mSerialBaseAddress, Control); + } + + return Status; } =20 --=20 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel