From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-x22f.google.com (mail-it0-x22f.google.com [IPv6:2607:f8b0:4001:c0b::22f]) (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 2FE7F2095D9C8 for ; Fri, 4 Aug 2017 01:01:09 -0700 (PDT) Received: by mail-it0-x22f.google.com with SMTP id 77so4453531itj.1 for ; Fri, 04 Aug 2017 01:03:21 -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=W5QzbWtEx2KTnmmaLswRExolXk5EVOwID8hdZX6xPqM=; b=YZ3vwIZimy8j88Fn5+Cl5wo903aegoieeD/cKhAiGzOzouXpfp+P4vkMxg66RKyhPg k3iX7zjc5ynW3W2e5HZFQHGhYepJX5SqCvUTUR+tVmRLt/kEW7q+76XDO9r2nHnr//Du jKYl3txW9uKC/JCpEh/Tpz/qNQg5JLCm1iV2o= 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=W5QzbWtEx2KTnmmaLswRExolXk5EVOwID8hdZX6xPqM=; b=b7ToyH64rEm+VhmVdxIdwMSBfJQt4Z2qtWm/7fcHGsuCrkkBCAk/Jjl4eByN9aPvKl Qbi/HAMTY7L+TPFG0BzkXPVGzBaI2EBQc/Gby1MgiNu8yewAUvGOgEq+isrCrad/a0za noIYzLE/ChcjcrhdZNbtoOPiRIwM8Ne4N9h4boRI1STwwpvD/8eMHKRexjDFgnMGs0mI TqrRyoGEmL/cySsGgAh1+dh5fPe8E7H+8hZhkummJRZZwEPP9ztph1K2/Ql4JdXal4St rzje1LT+u5jvIOcw7MmM64+PicL68cUGo26Xf5PiVV2Me0gWxpBlI5RmRMTzZR7USMEi q8ig== X-Gm-Message-State: AIVw11269rzVTgD22u5U/VpkTGLIaAhNSWMZpCsYLDy3Py54F3N6PxIB dfZZK692CjWBWW/g X-Received: by 10.36.209.196 with SMTP id w187mr1284974itg.70.1501833800767; Fri, 04 Aug 2017 01:03:20 -0700 (PDT) Received: from [10.229.36.134] ([119.145.15.121]) by smtp.gmail.com with ESMTPSA id h184sm455729ioa.70.2017.08.04.01.03.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Aug 2017 01:03:20 -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> From: Heyi Guo Message-ID: Date: Fri, 4 Aug 2017 16:02:49 +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: <65b2b345-941e-710e-60f6-65b341c750e6@linaro.org> 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:01:09 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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 >