From nobody Sun May 5 15:09:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97350+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97350+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1671002437; cv=none; d=zohomail.com; s=zohoarc; b=f8AqM+82dW/7mAKewwFNHw3YmBTvMlLZ+MRIzooFhVZDaeHZAQbpbeiIbb0xexsNHn5jS/JVdPGP6NfeAZ9hDyoGJZ/vCwCzygh/jMUY1uauRQeorWPm0x7FJTAQMXLfziIgZkRvVHSxb3z8P4YIN+I1Enwz+vvC7T4Be192ZYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671002437; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=YZM6Yr/sUxftcNO3WzB5ZahA4MLYaE0z9EX8XKVv6jk=; b=aK2SXMOnL0Pvp00m1DeLTe4MU9NVQ84d8NbKe881L18xdO/spuU3Wi+JFqPFTR6QVj9TlKgc0rYZKZjkOzPFDslhC4+IQDMHtqRn8+xA80xaP10wezJUoJ9WmSlLGSJdn36p8RMpvIFzU2Eo3ICIMHU2Ri442r3V2KePys33+SU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97350+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1671002437245532.1533702905101; Tue, 13 Dec 2022 23:20:37 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id SymvYY1788612xYNqS1JTE5j; Tue, 13 Dec 2022 23:20:36 -0800 X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web11.97545.1671002435405153571 for ; Tue, 13 Dec 2022 23:20:35 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10560"; a="382633300" X-IronPort-AV: E=Sophos;i="5.96,243,1665471600"; d="scan'208";a="382633300" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2022 23:20:34 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10560"; a="791202246" X-IronPort-AV: E=Sophos;i="5.96,243,1665471600"; d="scan'208";a="791202246" X-Received: from ksravanx-mobl.gar.corp.intel.com ([10.215.184.41]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2022 23:20:32 -0800 From: "Kavya" To: devel@edk2.groups.io Cc: Kavya , Guo Dong , Ray Ni , James Lu , Gua Guo Subject: [edk2-devel] [PATCH] UefiPayloadPkg/SerialPortLib: Enhance multi port behaviour Date: Wed, 14 Dec 2022 12:50:05 +0530 Message-Id: <20221214072005.1133-1-k.kavyax.sravanthi@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,k.kavyax.sravanthi@intel.com X-Gm-Message-State: 0uPLhDiavKyM9te8Gzwz0eLKx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1671002436; bh=Lxz5gJh2DNED+df+IkShtYL3yH2W80ZaQj43Pvym1no=; h=Cc:Date:From:Reply-To:Subject:To; b=tccNUgnuCsqBfYcjmsPk9E6bjorBAoBbPEkYeGTULBpeYpKsuINnuyf60uJxWOrvNBo ppg93Gl1vVvLSOwEb44KoO1x0yWA1sMlm8tsPqDA9qa56fGRWt04nMQEnWTd6E8U/NfXp 2o3HM2vmmLGhvLF3TOSyUT43oSNwLT7V9jM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1671002439394100002 Content-Type: text/plain; charset="utf-8" Add condition to return success if mUartCount is greater than zero in SerialPortInitialize() to avoid filling mUartInfo with the same hob data when SerialPortInitialize() is called multiple times. Also add proper conditions in SerialPortRead function to read the data properly from multiple UART's. Cc: Guo Dong Cc: Ray Ni Cc: James Lu Cc: Gua Guo Signed-off-by: Kavya Reviewed-by: Gua Guo =20 --- UefiPayloadPkg/Library/BaseSerialPortLibHob/BaseSerialPortLibHob.c | 37 ++= ++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/UefiPayloadPkg/Library/BaseSerialPortLibHob/BaseSerialPortLibH= ob.c b/UefiPayloadPkg/Library/BaseSerialPortLibHob/BaseSerialPortLibHob.c index 809fa2e9c9..84c56bd24d 100644 --- a/UefiPayloadPkg/Library/BaseSerialPortLibHob/BaseSerialPortLibHob.c +++ b/UefiPayloadPkg/Library/BaseSerialPortLibHob/BaseSerialPortLibHob.c @@ -138,6 +138,10 @@ SerialPortInitialize ( BOOLEAN MmioEnable; UINT8 Value; =20 + if (mUartCount > 0) { + return RETURN_SUCCESS; + } + GuidHob =3D GetFirstGuidHob (&gUniversalPayloadSerialPortInfoGuid); while (GuidHob !=3D NULL) { SerialPortInfo =3D (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *)GET_GUID_= HOB_DATA (GuidHob); @@ -329,6 +333,7 @@ SerialPortRead ( { UINTN BaseAddress; BOOLEAN UseMmio; + BOOLEAN IsNextPort; UINT8 *DataBuffer; UINTN BytesLeft; UINTN Result; @@ -353,6 +358,7 @@ SerialPortRead ( =20 DataBuffer =3D Buffer; BytesLeft =3D NumberOfBytes; + IsNextPort =3D FALSE; =20 Mcr =3D (UINT8)(SerialPortReadRegister (BaseAddress, R_UART_MCR, UseMm= io, Stride) & ~B_UART_MCR_RTS); =20 @@ -367,6 +373,12 @@ SerialPortRead ( // SerialPortWriteRegister (BaseAddress, R_UART_MCR, (UINT8)(Mcr | = B_UART_MCR_RTS), UseMmio, Stride); } + IsNextPort =3D TRUE; + break; + } + + if (IsNextPort) { + break; } =20 if (PcdGetBool (PcdSerialUseHardwareFlowControl)) { @@ -382,6 +394,10 @@ SerialPortRead ( *DataBuffer =3D SerialPortReadRegister (BaseAddress, R_UART_RXBUF, U= seMmio, Stride); } =20 + if ((!IsNextPort) && (*(--DataBuffer) !=3D '\0')) { + return Result; + } + Count++; } =20 @@ -409,10 +425,9 @@ SerialPortPoll ( BOOLEAN UseMmio; UINT8 Stride; UINT8 Count; - BOOLEAN Status; + BOOLEAN IsDataReady; =20 Count =3D 0; - Status =3D FALSE; while (Count < mUartCount) { BaseAddress =3D mUartInfo[Count].BaseAddress; UseMmio =3D mUartInfo[Count].UseMmio; @@ -423,7 +438,7 @@ SerialPortPoll ( continue; } =20 - Status =3D FALSE; + IsDataReady =3D FALSE; =20 // // Read the serial port status @@ -436,7 +451,7 @@ SerialPortPoll ( SerialPortWriteRegister (BaseAddress, R_UART_MCR, (UINT8)(SerialPo= rtReadRegister (BaseAddress, R_UART_MCR, UseMmio, Stride) & ~B_UART_MCR_RTS= ), UseMmio, Stride); } =20 - Status =3D TRUE; + IsDataReady =3D TRUE; } =20 if (PcdGetBool (PcdSerialUseHardwareFlowControl)) { @@ -446,10 +461,14 @@ SerialPortPoll ( SerialPortWriteRegister (BaseAddress, R_UART_MCR, (UINT8)(SerialPort= ReadRegister (BaseAddress, R_UART_MCR, UseMmio, Stride) | B_UART_MCR_RTS), = UseMmio, Stride); } =20 + if (IsDataReady) { + return IsDataReady; + } + Count++; } =20 - return Status; + return IsDataReady; } =20 /** @@ -603,6 +622,14 @@ SerialPortGetControl ( *Control |=3D EFI_SERIAL_INPUT_BUFFER_EMPTY; } =20 + if ((((*Control & EFI_SERIAL_OUTPUT_BUFFER_EMPTY) =3D=3D EFI_SERIAL_OU= TPUT_BUFFER_EMPTY) && + ((*Control & EFI_SERIAL_INPUT_BUFFER_EMPTY) !=3D EFI_SERIAL_INPUT_= BUFFER_EMPTY)) || + ((*Control & (EFI_SERIAL_DATA_SET_READY | EFI_SERIAL_CLEAR_TO_SEND= | + EFI_SERIAL_CARRIER_DETECT)) =3D=3D (EFI_SERIAL_DATA_SET_READY | EF= I_SERIAL_CLEAR_TO_SEND | + EFI_SERIAL_CARRIER_DETECT))) { + return RETURN_SUCCESS; + } + Count++; } =20 --=20 2.30.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97350): https://edk2.groups.io/g/devel/message/97350 Mute This Topic: https://groups.io/mt/95662178/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-