diff options
author | Britton Chesley <Brit.Chesley@amd.com> | 2023-05-16 15:40:50 -0500 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-07-03 12:23:26 +0000 |
commit | ed07a2bb11b358fdece44a760fc193d56f22cfb2 (patch) | |
tree | 0adbca744a59b5bae305384c04246e0a525f5c4e /MdeModulePkg | |
parent | 4f174696fd8fbd9cc29c9f172e8e83fe6da5b070 (diff) | |
download | edk2-ed07a2bb11b358fdece44a760fc193d56f22cfb2.tar.gz |
MdeModulePkg/UsbBusDxe: USB issue fix when the port reset
BZ #4456
Fixed a bug which led to an ASSERT due to the USB device
context being maintained after a port reset, but the
underlying XHCI context was uninitialized. Specifically,
Xhc->UsbDevContext is freed after a reset and only
re-allocates the default [0] enpoint transfer ring.
In order to avoid a memory leak, device enumeration is
performed after freeing the necessary buffers. This
allocates the Xhc->UsbDevContext for all endpoints of
the USB device.
Signed-off-by: Britton Chesley <Brit.Chesley@amd.com>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r-- | MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c index c25f3cc2f2..2826ac130e 100644 --- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c +++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c @@ -3,6 +3,7 @@ Usb Bus Driver Binding and Bus IO Protocol.
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -821,6 +822,7 @@ UsbIoPortReset ( EFI_TPL OldTpl;
EFI_STATUS Status;
UINT8 DevAddress;
+ UINT8 Config;
OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
@@ -882,8 +884,26 @@ UsbIoPortReset ( // is in CONFIGURED state.
//
if (Dev->ActiveConfig != NULL) {
- Status = UsbSetConfig (Dev, Dev->ActiveConfig->Desc.ConfigurationValue);
+ UsbFreeDevDesc (Dev->DevDesc);
+ Status = UsbRemoveConfig (Dev);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "UsbIoPortReset: Failed to remove configuration - %r\n", Status));
+ }
+
+ Status = UsbGetMaxPacketSize0 (Dev);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "UsbIoPortReset: Failed to get max packet size - %r\n", Status));
+ }
+
+ Status = UsbBuildDescTable (Dev);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "UsbIoPortReset: Failed to build descriptor table - %r\n", Status));
+ }
+
+ Config = Dev->DevDesc->Configs[0]->Desc.ConfigurationValue;
+
+ Status = UsbSetConfig (Dev, Config);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
@@ -892,6 +912,11 @@ UsbIoPortReset ( Status
));
}
+
+ Status = UsbSelectConfig (Dev, Config);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "UsbIoPortReset: Failed to set configuration - %r\n", Status));
+ }
}
ON_EXIT:
|