Re: [PATCH 0/1] Fix XhciDxe Timeouts

Wu, Hao A

-----Original Message-----
From: <> On Behalf Of Henz,
Sent: Thursday, September 3, 2020 7:03 AM
To: Wu, Hao A <>;
Cc: Wang, Jian J <>; Ni, Ray <>
Subject: Re: [edk2-devel] [PATCH 0/1] Fix XhciDxe Timeouts

Hello Hao,

Yes, I can provide patches for the UHCI and EHCI drivers. I haven't done any
of the work on either of these yet but will hopefully get to them in the next
day or so.

Thanks Patrick,

Could you help to add the UHCI and EHCI changes together with the existing XHCI patch into one series for the next version?
That will make a series which include 3 patches.

Best Regards,
Hao Wu

Patrick Henz

-----Original Message-----
From: Wu, Hao A []
Sent: Wednesday, September 2, 2020 12:09 AM
To: Henz, Patrick <>;
Cc: Wang, Jian J <>; Ni, Ray <>
Subject: RE: [PATCH 0/1] Fix XhciDxe Timeouts

-----Original Message-----
From: <>
Sent: Wednesday, September 2, 2020 2:55 AM
Cc: henz <>; Wang, Jian J <>;
Wu, Hao A <>; Ni, Ray <>
Subject: [PATCH 0/1] Fix XhciDxe Timeouts

From: henz <>

Timeouts in the XhciDxe driver are taking longer than expected due to
the timeout loops not accounting for code execution time. As en
example, 5 second timeouts have been observed to take around 36
seconds to complete.
Use SetTimer and Create/CheckEvent from Boot Services to determine
when timeout occurred. This patch was tested using forced timeouts and
print statements with QEmu as well as phycial hardware. The forced
timeouts were implemented in code via static variables that guaranteed
a timeout the first time the function with the broken timeout was called.


XhcExecTransfer (
static int do_once = 1; // test line
do {
Finished = XhcCheckUrbResult (Xhc, Urb);
if (do_once) Finished = 0; // test line
if (Finished) {
} while (!EFI_ERROR(TimerStatus) && EFI_ERROR(gBS->CheckEvent

do_once = 0; // test line

Using this forced timeout approach the correct timeouts were observed
on both hardware and in QEmu.

Similar broken timeout loops have been found in the Uhci and Ehci
drivers. This patch does not fix those issues.

Hello Patrick,

Besides the comments made by Ray in patch 1, could you help to provide 2
more patches for UHCI and EHCI drivers as well for complete enhancement?
Thanks in advance.

Best Regards,
Hao Wu

Cc: Jian J Wang <>
Cc: Hao A Wu <>
Cc: Ray Ni <>
Signed-off-by: Patrick Henz <>

Patrick Henz (1):
MdeModulePkg/XhciDxe: Fix Broken Timeouts

MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c | 28 ++++++++++++++++---
MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 34
2 files changed, 49 insertions(+), 13 deletions(-)


Join to automatically receive all group messages.