On 11/11/2015 10:06 AM, Kinney, Michael D wrote:
Heyi,

Yes.  I think computing the poll rate is a good addition to the TerminalDxe 
module.

If any of the information required to compute the rate is not available, then 
the #define default rate can be used.

Do you want to prepare a patch with this enhancement?
Sure, it's my pleasure.

Do you think it is necessary to still use the default rate if the calculated result is *larger* than it, to make it back compatible? It is possible some old code has wrong FIFO depth stated.

Thanks.

Thanks,

Mike

-----Original Message-----
From: edk2-devel [mailto:[email protected]] On Behalf Of Heyi Guo
Sent: Tuesday, November 10, 2015 5:27 PM
To: Kinney, Michael D; [email protected]
Cc: Tian, Feng
Subject: Re: [edk2] [RFC] Adaptively set serial terminal input polling interval



On 11/11/2015 04:34 AM, Kinney, Michael D wrote:
Heyi,

All timers in UEFI are the minimum time.  So the only way to guarantee that a 
FIFO will never overflow is to use flow control.

Setting the poll rate based on FIFO depth and baud rate, data bits, and stop 
bits with flow control disabled means it should work
most of the time, but another UEFI event notification function running at the 
same TPL or higher can block the Terminal event
notification function and input characters could be lost.
I agree that the current 20ms periodic timer can overflow depending in the FIFO 
depth and the baud rate, and that we could reduce
data loss in flow control disabled configurations if this periodic rate was 
computed instead of using a hard coded #define.  Another
constraint is the system timer interrupt rate provided by the Timer 
Architectural Protocol.  A request for a periodic timer event that is
faster than the current system timer rate will call the event notification 
function at the rate of the system timer.  So even if you
reduce the periodic timer event time to a computed value, the time between 
event notification function calls may not change.
Totally agree. However normally we will have platform configuration
interface for interrupt rate of system timer, like PCD or even driver
override, but I can't find any interface to configure polling rate of
the terminal driver, and I really don't like to override the whole
terminal driver when I only want to change the polling rate :). That's
the reason why I want to make a patch for terminal driver.

In order to prevent overflows, I think the timer rate in 100ns units could be 
computed as follows:

        Receive FIFO depth * (1 + DataBits + StopBits) * 10,000,000
        
----------------------------------------------------------------------------------
                                BaudRate

For example, a 16 byte receive FIFO with 8 data bits and 1 stop bit at 115200 
would be:

        16 * (1 + 8 + 1) * 10,000,000 / 115200 = 15277

Which is 0.00153 seconds or 1.53 ms.
Can I consider this as your agreement on calculating polling rate in
terminal driver?

After all, really appreciate your detailed answer on this issue.

Heyi

Best regards,

Mike

-----Original Message-----
From: edk2-devel [mailto:[email protected]] On Behalf Of Heyi Guo
Sent: Monday, November 09, 2015 10:23 PM
To: Kinney, Michael D; [email protected]
Cc: Tian, Feng
Subject: Re: [edk2] [RFC] Adaptively set serial terminal input polling interval

Hi Michael,

Yes we can see terminal input truncated when we use copy-paste to input
characters.

I don't quite understand the relationship between SerialInTimeOut and
timer event poll rate; and I don't see the periodic timer rate is to be
updated later; we are using 0.02ms period all over, aren't we?

If the timer event polls the serial device at a fixed rate, how can we
guarantee the FIFO of the device will not overflow during a burst input?

Thanks.

On 11/10/2015 01:25 AM, Kinney, Michael D wrote:
Heyi,

The function TerminalConInTimerHandler () computes a timeout based on the baud 
rate, data bits, and stop bits

         //
         // According to BAUD rate to calculate the timeout value.
         //
         SerialInTimeOut = (1 + Mode->DataBits + Mode->StopBits) * 2 * 1000000 / 
(UINTN) Mode->BaudRate;

The #define is used to set the initial periodic timer rate before the rest of 
the information to compute a timeout is known.

Are you observing an issue?

Mike

-----Original Message-----
From: edk2-devel [mailto:[email protected]] On Behalf Of Heyi
Guo
Sent: Monday, November 09, 2015 1:48 AM
To: [email protected]
Cc: Tian, Feng
Subject: [edk2] [RFC] Adaptively set serial terminal input polling interval

Hi All,

In MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf, the
polling interval is fixed by macro:

#define KEYBOARD_TIMER_INTERVAL         200000  // 0.02s

However, this may cause fast input to be truncated on some platform. For
example, we have a serial console with below features:
1. Baud rate: 115200
2. FIFO depth of UART device: 32

If we want to capture all input, we need to poll with the interval of 32
/ (115200 / (8 + 1 + 1)) = 2.8 ms, 8 + 1 + 1 for data bits + start bit +
stop bit.

So, I suppose to use a PCD to set the interval per platform, or
calculate from serial IO protocol IO Mode, which contains FIFO depth and
data bits, etc, and we can use 200000 as the maximum for compatibility,
or default value when fifo depth is 0.

Please let me know your comments.

Thanks.

Heyi
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to