public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ruiyu" <ruiyu.ni@intel.com>
To: "Zeng, Star" <star.zeng@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: Heyi Guo <heyi.guo@linaro.org>, Laszlo Ersek <lersek@redhat.com>
Subject: Re: [PATCH] MdeModulePkg SerialDxe: Process timeout consistently in SerialRead
Date: Fri, 4 Aug 2017 09:12:43 +0000	[thread overview]
Message-ID: <734D49CCEBEEF84792F5B80ED585239D5B9CC46A@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <1501835363-61956-1-git-send-email-star.zeng@intel.com>

Star,
3 minor comments below.

Thanks/Ray

> -----Original Message-----
> From: Zeng, Star
> Sent: Friday, August 4, 2017 4:29 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Heyi Guo <heyi.guo@linaro.org>; Ni,
> Ruiyu <ruiyu.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>
> Subject: [PATCH] MdeModulePkg SerialDxe: Process timeout consistently in
> SerialRead
> 
> https://lists.01.org/pipermail/edk2-devel/2017-July/012385.html
> reported 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.
> 
> This patch is to update SerialRead() to check SerialPortPoll() and read data
> through SerialPortRead() one byte by one byte, and check timeout against
> mSerialIoMode.Timeout if no input.
> 
> Cc: Heyi Guo <heyi.guo@linaro.org>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
>  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..43d33dba0c2a 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);
1. can you use EFI_TIMER_PERIOD_MICROSECONDS(1)?

> +      TimeOut += 10;
2. TImeOut++?

> +    }
> +    if (TimeOut >= mSerialIoMode.Timeout) {
3. if (TimeOut == ...) { ?

> +      break;
> +    }
> +    SerialPortRead (Buffer, 1);
> +    Count++;
> +    Buffer = (VOID *) ((UINT8 *) Buffer + 1);
>    }
> 
>    if (Count != *BufferSize) {
> --
> 2.7.0.windows.1



  reply	other threads:[~2017-08-04  9:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-04  8:29 [PATCH] MdeModulePkg SerialDxe: Process timeout consistently in SerialRead Star Zeng
2017-08-04  9:12 ` Ni, Ruiyu [this message]
2017-08-04  9:25   ` Zeng, Star
2017-08-04  9:53     ` Ni, Ruiyu
2017-08-15 23:30 ` Laszlo Ersek
2017-08-15 23:59   ` Kinney, Michael D
2017-08-16  2:02     ` Laszlo Ersek
2017-08-16  2:22       ` Zeng, Star
2017-08-16 10:21         ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=734D49CCEBEEF84792F5B80ED585239D5B9CC46A@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox