]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/XhciDxe: Error handle for USB slot initialization failure
authorLuo, Heng <heng.luo@intel.com>
Fri, 23 Oct 2020 01:26:11 +0000 (09:26 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 27 Oct 2020 01:09:28 +0000 (01:09 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3007

Currently UsbDevContext is not cleaned up if USB slot initialization is
failed, the wrong context data will affect next USB devices and
the USB devices can not be enumerated.
Need to disable slot if USB slot initialization is failed.

Below test cases are passed on UpXtreme:
a. USB 3.0 thumb drives can be recognized in UEFI shell
b. SUT can boot to Puppylinux  from USB3.0 mass storage,
 the storage can be recognized in linux
c. Plug in a USB  keyboard (hot plug) and enumeration is OK
 in UEFI shell and linux
d. Plug in a USB mouse(hot plug) and enumeration is OK in linux.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Heng Luo <heng.luo@intel.com>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c

index 9cb115363c8b7ef5992750515dd59839df50dce3..00e9cc63d63e4abdda00e65059afd1b324e03d29 100644 (file)
@@ -2,7 +2,7 @@
 \r
   XHCI transfer scheduling routines.\r
 \r
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2020, Intel Corporation. All rights reserved.<BR>\r
 Copyright (c) Microsoft Corporation.<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -2279,6 +2279,9 @@ XhcInitializeDeviceSlot (
     DeviceAddress = (UINT8) ((DEVICE_CONTEXT *) OutputContext)->Slot.DeviceAddress;\r
     DEBUG ((EFI_D_INFO, "    Address %d assigned successfully\n", DeviceAddress));\r
     Xhc->UsbDevContext[SlotId].XhciDevAddr = DeviceAddress;\r
+  } else {\r
+    DEBUG ((DEBUG_INFO, "    Address %d assigned unsuccessfully\n"));\r
+    XhcDisableSlotCmd (Xhc, SlotId);\r
   }\r
 \r
   return Status;\r
@@ -2489,7 +2492,11 @@ XhcInitializeDeviceSlot64 (
     DeviceAddress = (UINT8) ((DEVICE_CONTEXT_64 *) OutputContext)->Slot.DeviceAddress;\r
     DEBUG ((EFI_D_INFO, "    Address %d assigned successfully\n", DeviceAddress));\r
     Xhc->UsbDevContext[SlotId].XhciDevAddr = DeviceAddress;\r
+  } else {\r
+    DEBUG ((DEBUG_INFO, "    Address %d assigned unsuccessfully\n"));\r
+    XhcDisableSlotCmd64 (Xhc, SlotId);\r
   }\r
+\r
   return Status;\r
 }\r
 \r