mirror of https://github.com/acidanthera/audk.git
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>
This commit is contained in:
parent
4f174696fd
commit
ed07a2bb11
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue