public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Jeremy Linton" <jeremy.linton@arm.com>
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 <jeremy.linton@arm.com>
Subject: [PATCH] MdeModulePkg/UsbBusDxe: On reset rebuild descriptor table
Date: Mon, 27 Apr 2020 17:16:25 -0500	[thread overview]
Message-ID: <20200427221625.599302-1-jeremy.linton@arm.com> (raw)

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 != 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 <jeremy.linton@arm.com>
---
 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.
   //
   if (Dev->ActiveConfig != NULL) {
+    Status = UsbBuildDescTable (Dev);
+
+    if (EFI_ERROR (Status)) {
+      DEBUG ((EFI_D_ERROR, "UsbIoPortReset: failed to build descriptor table for %d - %r\n",
+                 Dev->Address, Status));
+      goto ON_EXIT;
+    }
+
     Status = UsbSetConfig (Dev, Dev->ActiveConfig->Desc.ConfigurationValue);
 
     if (EFI_ERROR (Status)) {
-- 
2.24.1


             reply	other threads:[~2020-04-27 22:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-27 22:16 Jeremy Linton [this message]
2020-04-28  0:15 ` [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: On reset rebuild descriptor table Guomin Jiang
2020-04-28  0:44   ` Jeremy Linton
2020-04-28  1:03     ` Guomin Jiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200427221625.599302-1-jeremy.linton@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox