From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.164.1588025788267877016 for ; Mon, 27 Apr 2020 15:16:28 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: jeremy.linton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D54BD31B; Mon, 27 Apr 2020 15:16:26 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CBC023F68F; Mon, 27 Apr 2020 15:16:26 -0700 (PDT) From: "Jeremy Linton" To: devel@edk2.groups.io Cc: hao.a.wu@intel.com, ray.ni@intel.com, michael.d.kinney@intel.com, feng.tian@intel.com, jian.j.wang@intel.com, ard.biesheuvel@arm.com, Jeremy Linton Subject: [PATCH] MdeModulePkg/UsbBusDxe: On reset rebuild descriptor table Date: Mon, 27 Apr 2020 17:16:25 -0500 Message-Id: <20200427221625.599302-1-jeremy.linton@arm.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable During port reset, the device descriptors should be checked before attempting to set an endpoint configuration. In particular this fixes a crash due to ASSERT(TrsRing !=3D NULL) in XhcSyncTrsRing(). That crash happens during error recovery on devices attached to XHCI hosts. This is because the port disable clears and deallocats all the EP data structures. When the port is reconfigured without first requesting the EP descriptors, XhcSetConfigCmd[64]() is not being called because the NumConfigurations remains 0. We could attempt to rebuild the EP descriptions directly from the XHCI driver. OTOH, its probably good practice to assure the device description is what we expect from within the core USB subsystem during reset. Signed-off-by: Jeremy Linton --- MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c b/MdeModulePkg/Bus/Usb= /UsbBusDxe/UsbBus.c index 4b4915c019..17bb691bf8 100644 --- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c +++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c @@ -874,6 +874,14 @@ UsbIoPortReset ( // is in CONFIGURED state.=0D //=0D if (Dev->ActiveConfig !=3D NULL) {=0D + Status =3D UsbBuildDescTable (Dev);=0D +=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((EFI_D_ERROR, "UsbIoPortReset: failed to build descriptor tab= le for %d - %r\n",=0D + Dev->Address, Status));=0D + goto ON_EXIT;=0D + }=0D +=0D Status =3D UsbSetConfig (Dev, Dev->ActiveConfig->Desc.ConfigurationVal= ue);=0D =0D if (EFI_ERROR (Status)) {=0D --=20 2.24.1