From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-x22d.google.com (mail-io0-x22d.google.com [IPv6:2607:f8b0:4001:c06::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C87812095D9C8 for ; Fri, 4 Aug 2017 01:06:25 -0700 (PDT) Received: by mail-io0-x22d.google.com with SMTP id m88so3425868iod.2 for ; Fri, 04 Aug 2017 01:08:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=Ff0EKSwVO4DtKqkbs/2KlhDIm3ABAD/FNhq2QXJzgjQ=; b=Up5Hbj76yGrTXy5CcHYxp69kU7Vv0HdhUfNiMyujotg3RGPJnTKhA97BoiXvkk+P/v HKZdXfm3PV8mUhrssnVYvSw4uSPyjM+BgKUErfWF7/ceCfLTdhN8me5W4baKL+iDfNmL YzWuXQ9z8fED8t/m4PFoyOrfTu35D0J2wzLjI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=Ff0EKSwVO4DtKqkbs/2KlhDIm3ABAD/FNhq2QXJzgjQ=; b=bq+FO8RRTNBLyTGRrd6e+VKGem5p44zEdiFkeVGC1fH17Kwjur1nPmmIUJGgfAl51H ezzZb4ukTvqo9SKKcdH2tg8VV6tN/mBvcJFCJT8GexgjWQwrGyQMTi/TZYW3l4k3LkB1 oSUkFw5Tit4p+lwsvCnYViTvugLvAvU9EMuresmueBdkciHCBq919QQfW06rDUxSuiEH uaJ/KZqeLEWkd4y4NAF5Dm4quSX0v+odPb4foB6r61xkAlzw/hI53OUkUAM6RmtSM6sC uOsUTvvUJXDc88Q3Wc71tD8hrtoahrsGY5vWI8y26QQLfVRjlSwgRWphOMmgKMiATEKs EI7Q== X-Gm-Message-State: AHYfb5jq/MkI291nUnv0upa/YKGZa/Yk4ZVKaGq0tIc1PUpg53aVJxRb rMgoKF3KMA+prYot X-Received: by 10.107.18.40 with SMTP id a40mr1526736ioj.282.1501834117694; Fri, 04 Aug 2017 01:08:37 -0700 (PDT) Received: from [10.229.36.134] ([119.145.15.121]) by smtp.gmail.com with ESMTPSA id q7sm475911iof.24.2017.08.04.01.08.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Aug 2017 01:08:37 -0700 (PDT) To: "Zeng, Star" , "edk2-devel@lists.01.org" , "Ni, Ruiyu" , "Laszlo Ersek (lersek@redhat.com)" References: <0C09AFA07DD0434D9E2A0C6AEB0483103B8F41C6@shsmsx102.ccr.corp.intel.com> <65b2b345-941e-710e-60f6-65b341c750e6@linaro.org> <0C09AFA07DD0434D9E2A0C6AEB0483103B8F9E63@shsmsx102.ccr.corp.intel.com> From: Heyi Guo Message-ID: Date: Fri, 4 Aug 2017 16:08:48 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103B8F9E63@shsmsx102.ccr.corp.intel.com> Subject: Re: MdeModulePkg/SerialDxe: Inconsistent timeout processing in SerialRead 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: , X-List-Received-Date: Fri, 04 Aug 2017 08:06:26 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit No problem at all and thanks a lot for fixing the issue :) Gary (Heyi Guo) 在 8/4/2017 4:05 PM, Zeng, Star 写道: > Oh, sorry, I forgot it because of busying on other things. I will post it soon. > Thanks for your reminder. > > Star > -----Original Message----- > From: Heyi Guo [mailto:heyi.guo@linaro.org] > Sent: Friday, August 4, 2017 4:03 PM > To: Zeng, Star ; edk2-devel@lists.01.org; Ni, Ruiyu ; Laszlo Ersek (lersek@redhat.com) > Subject: Re: [edk2] MdeModulePkg/SerialDxe: Inconsistent timeout processing in SerialRead > > Hi Star, > > The patch works well on our platform. Would you merge it to EDK2 main stream or do you like me to post it to the mailing-list? > > Thanks and regards, > > Gary (Heyi Guo) > > > 在 7/18/2017 6:59 PM, Heyi Guo 写道: >> Hi Star, >> >> I think your proposed patch is fine. >> >> Thanks. >> >> Gary (Heyi Guo) >> >> >> 在 7/18/2017 4:39 PM, Zeng, Star 写道: >>> Gary, >>> SerialDxe is a wrapper of SerialPortLib to produce serial io protocol. >>> If let SerialDxe to handle the TimeOut, seemingly it can only check >>> SerialPortPoll() and read data by SerialPortRead() one byte by one >>> byte, for example like below. >>> Do you have any proposed patch? >>> >>> Ray and Laszlo, >>> Do you have any comments? >>> >>> >>> ==================== >>> debf0d1b85e7a30defd29838abb20a44dd9ec69b >>> MdeModulePkg/Universal/SerialDxe/SerialIo.c | 18 ++++++++++++++++-- >>> 1 file changed, 16 insertions(+), 2 deletions(-) >>> >>> diff --git a/MdeModulePkg/Universal/SerialDxe/SerialIo.c >>> b/MdeModulePkg/Universal/SerialDxe/SerialIo.c >>> index d2383e56dd8f..b05603d7f3b5 100644 >>> --- a/MdeModulePkg/Universal/SerialDxe/SerialIo.c >>> +++ b/MdeModulePkg/Universal/SerialDxe/SerialIo.c >>> @@ -465,11 +465,25 @@ SerialRead ( >>> ) >>> { >>> UINTN Count; >>> + UINTN TimeOut; >>> Count = 0; >>> - if (SerialPortPoll ()) { >>> - Count = SerialPortRead (Buffer, *BufferSize); >>> + while (Count < *BufferSize) { >>> + TimeOut = 0; >>> + while (TimeOut < mSerialIoMode.TimeOut) { >>> + if (SerialPortPoll ()) { >>> + break; >>> + } >>> + gBS->Stall (10); >>> + TimeOut += 10; >>> + } >>> + if (TimeOut >= mSerialIoMode.TimeOut) { >>> + break; >>> + } >>> + SerialPortRead (Buffer, 1); >>> + Count++; >>> + Buffer = (VOID *) ((UINT8 *) Buffer + 1); >>> } >>> if (Count != *BufferSize) { >>> ==================== >>> >>> >>> Thanks, >>> Star >>> -----Original Message----- >>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf >>> Of Heyi Guo >>> Sent: Monday, July 17, 2017 12:23 PM >>> To: edk2-devel@lists.01.org >>> Subject: [edk2] MdeModulePkg/SerialDxe: Inconsistent timeout >>> processing in SerialRead >>> >>> Hi Folks, >>> >>> In SerialRead function in >>> MdeModulePkg/Universal/SerialDxe/SerialIo.c, >>> it seems the timeout processing in SerialRead is not consistent. >>> >>> Since SerialPortPoll only checks the status of serial port and >>> returns immediately, and SerialPortRead does not really implement a >>> time out mechanism and will always wait for enough input, it will >>> cause below >>> results: >>> >>> 1. If there is no serial input at all, this interface will return >>> timeout immediately without any waiting; >>> >>> 2. If there is A characters in serial port FIFO, and caller requires >>> A+1 characters, it will wait until a new input is coming and timeout >>> will not really occur. >>> >>> As SerialPortLib is a simple library implementation, I think it is >>> better to improve SerialIoDxe driver instead of SerialPortLib. >>> >>> Please let me know your comments about this. >>> >>> Thanks and regards, >>> >>> Gary (Heyi Guo) >>> >>> EFI_STATUS >>> EFIAPI >>> SerialRead ( >>> IN EFI_SERIAL_IO_PROTOCOL *This, >>> IN OUT UINTN *BufferSize, >>> OUT VOID *Buffer >>> ) >>> { >>> UINTN Count; >>> >>> Count = 0; >>> >>> if (SerialPortPoll ()) { >>> Count = SerialPortRead (Buffer, *BufferSize); >>> } >>> >>> if (Count != *BufferSize) { >>> *BufferSize = Count; >>> return EFI_TIMEOUT; >>> } >>> >>> return EFI_SUCCESS; >>> } >>> >>> _______________________________________________ >>> edk2-devel mailing list >>> edk2-devel@lists.01.org >>> https://lists.01.org/mailman/listinfo/edk2-devel