public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Bug report: serial timeout gets overwritten shortly after setting it
@ 2021-11-21 17:52 nicholasbishop
  2021-11-23  3:54 ` [edk2-devel] " Michael D Kinney
  0 siblings, 1 reply; 3+ messages in thread
From: nicholasbishop @ 2021-11-21 17:52 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 740 bytes --]

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.

[-- Attachment #2: Type: text/html, Size: 772 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] Bug report: serial timeout gets overwritten shortly after setting it
  2021-11-21 17:52 Bug report: serial timeout gets overwritten shortly after setting it nicholasbishop
@ 2021-11-23  3:54 ` Michael D Kinney
  2021-12-04  7:19   ` nicholasbishop
  0 siblings, 1 reply; 3+ messages in thread
From: Michael D Kinney @ 2021-11-23  3:54 UTC (permalink / raw)
  To: devel@edk2.groups.io, nicholasbishop@gmail.com, Kinney, Michael D

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. 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] Bug report: serial timeout gets overwritten shortly after setting it
  2021-11-23  3:54 ` [edk2-devel] " Michael D Kinney
@ 2021-12-04  7:19   ` nicholasbishop
  0 siblings, 0 replies; 3+ messages in thread
From: nicholasbishop @ 2021-12-04  7:19 UTC (permalink / raw)
  To: Michael D Kinney, devel

[-- Attachment #1: Type: text/plain, Size: 225 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 237 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-04  7:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-21 17:52 Bug report: serial timeout gets overwritten shortly after setting it nicholasbishop
2021-11-23  3:54 ` [edk2-devel] " Michael D Kinney
2021-12-04  7:19   ` nicholasbishop

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox