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.2259.1588034653621710424 for ; Mon, 27 Apr 2020 17:44:14 -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 2D22130E; Mon, 27 Apr 2020 17:44:12 -0700 (PDT) Received: from [192.168.122.166] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CE1B23F73D; Mon, 27 Apr 2020 17:44:11 -0700 (PDT) Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: On reset rebuild descriptor table To: "Jiang, Guomin" , "devel@edk2.groups.io" Cc: "Wu, Hao A" , "Ni, Ray" , "Kinney, Michael D" , "Tian, Feng" , "Wang, Jian J" , "ard.biesheuvel@arm.com" References: <20200427221625.599302-1-jeremy.linton@arm.com> From: "Jeremy Linton" Message-ID: <2153b0dc-e6d8-4483-7f11-48c24ee24ed3@arm.com> Date: Mon, 27 Apr 2020 19:44:07 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Hi! On 4/27/20 7:15 PM, Jiang, Guomin wrote: > Hi Jeremy, > > You can refer https://edk2.groups.io/g/devel/message/58125 for discussion about this solution. Oh fun, odd how a bug can exist in a code base for years and then this happens.. I will move the discussion there. Thanks, > > Two issue I found: > 1. Memory leakage may occur if doing so and I am investigating it. It seems our solutions differ a bit? > 2. It test pass with OVMF but fail in real platform, and I am figuring out the flow. Hmm, I've been seeing this on a RPI with an attached USB3 hub and 5 bay USB JBOD. (there is another problem but the reset crash is keeps the machine from booting). > > Best Regards > Guomin > >> -----Original Message----- >> From: devel@edk2.groups.io On Behalf Of Jeremy >> Linton >> Sent: Tuesday, April 28, 2020 6:16 AM >> To: devel@edk2.groups.io >> Cc: Wu, Hao A ; Ni, Ray ; Kinney, >> Michael D ; Tian, Feng ; >> Wang, Jian J ; ard.biesheuvel@arm.com; Jeremy >> Linton >> Subject: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: On reset rebuild >> descriptor table >> >> 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 >> --- >> 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 >> >> >> -=-=-=-=-=-= >> Groups.io Links: You receive all messages sent to this group. >> >> View/Reply Online (#58193): https://edk2.groups.io/g/devel/message/58193 >> Mute This Topic: https://groups.io/mt/73315690/4399222 >> Group Owner: devel+owner@edk2.groups.io >> Unsubscribe: https://edk2.groups.io/g/devel/unsub [guomin.jiang@intel.com] >> -=-=-=-=-=-= >