Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MdeModulePkg/XhciDxe: Fix Broken Timeouts #968

Merged
merged 1 commit into from
Sep 29, 2020

Conversation

hwu25
Copy link
Member

@hwu25 hwu25 commented Sep 29, 2020

https://edk2.groups.io/g/devel/message/65543
https://bugzilla.tianocore.org/show_bug.cgi?id=2948

Cover-letter:
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.

Example:

XhcExecTransfer (
.
.
)
{
.
.
static int do_once = 1; // test line
.
.
do {
Finished = XhcCheckUrbResult (Xhc, Urb);
if (do_once) Finished = 0; // test line
if (Finished) {
break;
}
gBS->Stall (XHC_1_MICROSECOND);
} while (EFI_ERROR(gBS->CheckEvent (TimeoutEvent)));

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.

Commit message:
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2948

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.

Cc: Jian J Wang jian.j.wang@intel.com
Cc: Hao A Wu hao.a.wu@intel.com
Cc: Ray Ni ray.ni@intel.com
Signed-off-by: Patrick Henz patrick.henz@hpe.com
Reviewed-by: Hao A Wu hao.a.wu@intel.com

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2948

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.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Patrick Henz <patrick.henz@hpe.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
@hwu25 hwu25 added the push Auto push patch series in PR if all checks pass label Sep 29, 2020
@mergify mergify bot merged commit 71dd80f into tianocore:master Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
push Auto push patch series in PR if all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants