public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: Star Zeng <star.zeng@intel.com>, edk2-devel@lists.01.org
Cc: Laszlo Ersek <lersek@redhat.com>, Ruiyu Ni <ruiyu.ni@intel.com>
Subject: Re: [PATCH V2] MdeModulePkg SerialDxe: Handle Timeout change more robustly
Date: Wed, 8 Nov 2017 14:35:32 +0000	[thread overview]
Message-ID: <4fab5c71-d4a9-ee2d-7017-a4c7047713b1@linaro.org> (raw)
In-Reply-To: <1510018605-84896-1-git-send-email-star.zeng@intel.com>

Hi Star,

On 07/11/17 01:36, Star Zeng wrote:
> https://lists.01.org/pipermail/edk2-devel/2017-October/016479.html
> reported "Xen Console input very slow in recent UEFI" that appears
> after 4cf3f37c87ba1f9d58072444bd735e40e4779e70 "MdeModulePkg
> SerialDxe: Process timeout consistently in SerialRead".
> 
> Julien did more debugging and find out the following is happening in
> TerminalConInTimerHandler (MdeModulePkg/Universal/Console/TerminalDxe)
> when a character is received:
> 1) GetControl will return EFI_SERIAL_INPUT_BUFFER_EMPTY unset
>    => Entering in the loop to fetch character from the serial
> 2) GetOneKeyFromSerial()
>    => Return directly with the character read
> 3) Looping as the fifo is not full and no error
> 4) GetOneKeyFromSerial() -> SerialRead()
>    => No more character so SerialPortPoll() will return FALSE and loop
>       until timeout
>    => Return EFI_TIMEOUT
> 5) Exiting the loop from TerminalConInTimerHandler
> 6) Characters are printed
> 
> After some investigation, I found it is related to the Timeout value.
> 
> The Timeout is 1000000 (1s) by default to follow UEFI spec.
> And the Terminal driver will recalculate and set the Timeout value
> based on the properties of UART in TerminalDriverBindingStart()/
> TerminalConInTimerHandler().
> 
>    SerialInTimeOut = 0;
>    if (Mode->BaudRate != 0) {
>      //
>      // According to BAUD rate to calculate the timeout value.
>      //
>      SerialInTimeOut = (1 + Mode->DataBits + Mode->StopBits) *
>                        2 * 1000000 / (UINTN) Mode->BaudRate;
>    }
> 
> For example, based on the PCD values of PcdUartDefaultBaudRate,
> PcdUartDefaultDataBits and PcdUartDefaultStopBits, SerialInTimeOut =
> (1 + 8  + 1) * 2 * 1000000 / (UINTN) 115200 = 173 (us).
> 
> When SerialDxe is used,
> TerminalDriverBindingStart()/TerminalConInTimerHandler() ->
>    SerialIo->SetAttributes() ->
>      SerialSetAttributes() ->
>        SerialPortSetAttributes()
> 
> Some implementations of SerialPortSetAttributes() could handle the
> input parameters and return RETURN_SUCCESS, for example
> BaseSerialPortLib16550, then Timeout value will be changed to 173 (us),
> no "slow down" will be observed.
> But some implementations of SerialPortSetAttributes() just return
> RETURN_UNSUPPORTED, for example XenConsoleSerialPortLib, then Timeout
> value will be not changed and kept 1000000 (1s), "slow down" will be
> observed.
> 
> SerialPortLib instance can be enhanced to
> 1. Handle the input parameters and return status accordingly instead of
> just returning RETURN_UNSUPPORTED in SerialPortSetAttributes().
> 2. Just return RETURN_SUCCESS instead of RETURN_UNSUPPORTED in
> SerialPortSetAttributes() if the instance does not care the input
> parameters at all.
> 
> And SerialDxe can also be enhanced like this patch to be more robust
> to handle Timeout change.
> 
> Cc: Julien Grall <julien.grall@linaro.org>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Compare against the original parameters
>    Suggested-by: Laszlo Ersek <lersek@redhat.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng <star.zeng@intel.com>

Tested-by: Julien Grall <julien.grall@linaro.org>

Cheers,

-- 
Julien Grall


  parent reply	other threads:[~2017-11-08 14:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-07  1:36 [PATCH V2] MdeModulePkg SerialDxe: Handle Timeout change more robustly Star Zeng
2017-11-07 18:27 ` Laszlo Ersek
2017-11-07 18:31   ` Laszlo Ersek
2017-11-08 14:35 ` Julien Grall [this message]
2017-11-09  1:02   ` Zeng, Star

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=4fab5c71-d4a9-ee2d-7017-a4c7047713b1@linaro.org \
    --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