Bug report: serial timeout gets overwritten shortly after setting it


nicholasbishop@...
 

Hi, I have a bug to report with the serial I/O protocol. Using the SetAttributes function to change the timeout initially works, but after a short amount of time the timeout gets reset to 173 microseconds.

I believe this is likely due to the implementation of the simple text input protocol, which alters the serial timeout:
https://github.com/tianocore/edk2/blob/e1e7306b54147e65cb7347b060e94f336d4a82d2/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c#L549

I've created a full example here:
https://github.com/nicholasbishop/edk2/commit/d6087f863a48f3c7812f47ea21d5d673adb8d754

The example sets the timeout to 1s which works correctly, then sleeps for 1s and reads the timeout value again. The timeout is now 173ms.


Michael D Kinney
 

Hi Nicholas,

How did you open the Serial I/O Protocol?

If you open BY_DRIVER or EXCLUSIVE, then it should disconnect the Terminal
driver from the Serial I/O Protocol and allow you to change the timeout and
keep that timeout setting. For your UEFI application test case, the open
mode of EXCLUSIVE would be the best choice.

You can also use DisconnectController() to disconnect the Terminal driver
from the Serial I/O Protocol you want to manage and change the timeout and
then open it to use it. EXCLUSIVE does the disconnect for you.

In order to do an OpenProtcol() with the appropriate open type or
DisconnectController(), you will want to use LocateHandle() instead of
LocateProtocol() to get an EFI_HANDLE with he correct Serial I/O Protocol.
You may need to evaluate the Device Path Protocol instance to make sure
you have selected the correct Serial I/O Protocol instance if the
platform has more than one.

The UEFI Driver Writer's Guide also has a description of these issues.
Please see section 5.1.3.4.

https://tianocore-docs.github.io/edk2-UefiDriverWritersGuide/draft/5_uefi_services/51_services_that_uefi_drivers_commonly_use/513_handle_database_and_protocol_services.html#513-handle-database-and-protocol-services

Thanks,

Mike

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of nicholasbishop@gmail.com
Sent: Sunday, November 21, 2021 9:52 AM
To: devel@edk2.groups.io
Subject: [edk2-devel] Bug report: serial timeout gets overwritten shortly after setting it

Hi, I have a bug to report with the serial I/O protocol. Using the SetAttributes function to change the timeout initially works, but after a short amount of time the timeout gets reset to 173 microseconds.

I believe this is likely due to the implementation of the simple text input protocol, which alters the serial timeout:
https://github.com/tianocore/edk2/blob/e1e7306b54147e65cb7347b060e94f336d4a82d2/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c#L549

I've created a full example here:
https://github.com/nicholasbishop/edk2/commit/d6087f863a48f3c7812f47ea21d5d673adb8d754

The example sets the timeout to 1s which works correctly, then sleeps for 1s and reads the timeout value again. The timeout is now 173ms.


nicholasbishop@...
 

Just getting back to this, thanks for the solution and explanation. I've confirmed that using LocateHandle followed by OpenProtocol with EFI_OPEN_PROTOCOL_EXCLUSIVE works for me as you suggested.

Thanks again!
-Nicholas