From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web12.6411.1603348605260923949 for ; Wed, 21 Oct 2020 23:36:45 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: heng.luo@intel.com) IronPort-SDR: IxIbYhi416EP7WJKP+QKafm6vyX0gP4Zj7+UbikW/RC9lzKfc3+54YMaB4W5ehBW5SG0ciSx+y I7ymDWaicW5w== X-IronPort-AV: E=McAfee;i="6000,8403,9781"; a="163989008" X-IronPort-AV: E=Sophos;i="5.77,403,1596524400"; d="scan'208";a="163989008" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2020 23:36:44 -0700 IronPort-SDR: kYzw2234fwPARn4IgtDzhIaOeGu8zvAXyfUDUEJEoeJJg1ZsTURxtYh+nah1Jg+ROg0jtkGcf8 YTtBctdFo9/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,403,1596524400"; d="scan'208";a="524163837" Received: from hengluo-dev.ccr.corp.intel.com ([10.239.153.154]) by fmsmga005.fm.intel.com with ESMTP; 21 Oct 2020 23:36:43 -0700 From: "Heng Luo" To: devel@edk2.groups.io Cc: Ray Ni , Hao A Wu Subject: [Patch V3] MdeModulePkg/XhciDxe: Error handle for USB slot initialization failure Date: Thu, 22 Oct 2020 14:36:36 +0800 Message-Id: <20201022063636.4609-1-heng.luo@intel.com> X-Mailer: git-send-email 2.24.0.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3007 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 Cc: Hao A Wu Signed-off-by: Heng Luo --- MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/Pc= i/XhciDxe/XhciSched.c index 9cb115363c..98887c5f74 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c @@ -2,7 +2,7 @@ =0D XHCI transfer scheduling routines.=0D =0D -Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2011 - 2020, Intel Corporation. All rights reserved.
=0D Copyright (c) Microsoft Corporation.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -2279,6 +2279,9 @@ XhcInitializeDeviceSlot ( DeviceAddress =3D (UINT8) ((DEVICE_CONTEXT *) OutputContext)->Slot.Dev= iceAddress;=0D DEBUG ((EFI_D_INFO, " Address %d assigned successfully\n", DeviceAd= dress));=0D Xhc->UsbDevContext[SlotId].XhciDevAddr =3D DeviceAddress;=0D + } else {=0D + DEBUG ((DEBUG_INFO, " Address %d assigned unsuccessfully\n"));=0D + Status =3D XhcDisableSlotCmd (Xhc, SlotId);=0D }=0D =0D return Status;=0D @@ -2489,7 +2492,11 @@ XhcInitializeDeviceSlot64 ( DeviceAddress =3D (UINT8) ((DEVICE_CONTEXT_64 *) OutputContext)->Slot.= DeviceAddress;=0D DEBUG ((EFI_D_INFO, " Address %d assigned successfully\n", DeviceAd= dress));=0D Xhc->UsbDevContext[SlotId].XhciDevAddr =3D DeviceAddress;=0D + } else {=0D + DEBUG ((DEBUG_INFO, " Address %d assigned unsuccessfully\n"));=0D + Status =3D XhcDisableSlotCmd64 (Xhc, SlotId);=0D }=0D +=0D return Status;=0D }=0D =0D --=20 2.24.0.windows.2