From nobody Thu May 2 10:02:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+66566+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+66566+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=nvidia.com ARC-Seal: i=1; a=rsa-sha256; t=1603448713; cv=none; d=zohomail.com; s=zohoarc; b=a2rr2TYon5WZWRT3vkL8cOjxkbM5jSXb1+gxnN00lEIOnnibGhtEnV2JIm4gJpAmQ/eXjtLFeSSroUjqowMXA/2oUQmItGXytmF/ZT43Epd4O+H85hqOjzL4ff1lMYCodx4EThHKf31Vd8xMsIvwjNdbTjyAcH3rUgitEooxvcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603448713; h=Content-Type:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=WjbehfCUcBrLstTJalmDMkWa3yIJ1V2iuBi4UR4EvwQ=; b=W4pWFyyfiNfP8DMFGlj6x8k+tey7jc2s8RvzzQ61AsV19T4lBkDMgumrL3PlCWfPjay8ihk6k+dpsQXX4nKi2YWWsrDXWpCX9uxfLiahxX1BXbSaPC3GKiCfOuj/BiVhZIr8Phlq//AUK32n4BvTgS85lCfplvYXqykRfpJ4oYw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+66566+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1603448713060945.5242790183448; Fri, 23 Oct 2020 03:25:13 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id awBaYY1788612xWv5VqMl4sr; Fri, 23 Oct 2020 03:25:12 -0700 X-Received: from hqnvemgate24.nvidia.com (hqnvemgate24.nvidia.com [216.228.121.143]) by mx.groups.io with SMTP id smtpd.web12.6659.1603447144084294397 for ; Fri, 23 Oct 2020 02:59:04 -0700 X-Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Fri, 23 Oct 2020 02:57:29 -0700 X-Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 23 Oct 2020 09:58:58 +0000 X-Received: from thunderball.nvidia.com (10.124.1.5) by mail.nvidia.com (172.20.187.12) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Fri, 23 Oct 2020 09:58:57 +0000 From: Jon Hunter To: , , , CC: , Jon Hunter Subject: [edk2-devel] [RESEND PATCH V2] MdeModulePkg/XhciDxe: Retry device slot init on failure Date: Fri, 23 Oct 2020 10:58:55 +0100 Message-ID: <20201023095855.31735-1-jonathanh@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,jonathanh@nvidia.com X-Gm-Message-State: rK8rc5H1FJlGQg9eAcrQPRfLx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1603448712; bh=mX7MBqUSLdai3QvHTBxprykRKlAW9hH5cjpBGguKAp4=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=OfNErD1IVBA0X0h8LDW11ker3DzIVsvmgFUJzFCz2RsvxD4H5FbCHQ9JY8k/UBShxEj oIobphF7XvcSwZvMEEsgkmQbynJ+3jpA2bAjihvk1D/KuoeZQIKxVHdtzWezIm402E6A4 l+Vw3aVxA+5u0N8pqtEVPb8H0BHCUAqfefk= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" With some super-speed USB mass storage devices it has been observed that a USB transaction error may occur when attempting the set the device address during enumeration. According the the xHCI specification (section 4.6.5) ... "A USB Transaction ErrorCompletion Code for an Address Device Command may be due to a Stall response from a device. Software should issue a Disable Slot Commandfor the Device Slot then an Enable Slot Command to recover from this error." To fix this, retry the device slot initialization if it fails due to a device error. Signed-off-by: Jon Hunter --- MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 34 +++++++++++++++++------- MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h | 1 + 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/Pc= i/XhciDxe/XhciSched.c index 2e0867af7997..45423869be81 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c @@ -1684,9 +1684,11 @@ XhcPollPortStatusChange ( EFI_STATUS Status; UINT8 Speed; UINT8 SlotId; + UINT8 Retries; USB_DEV_ROUTE RouteChart; =20 Status =3D EFI_SUCCESS; + Retries =3D XHC_INIT_DEVICE_SLOT_RETRIES; =20 if ((PortState->PortChangeStatus & (USB_PORT_STAT_C_CONNECTION | USB_POR= T_STAT_C_ENABLE | USB_PORT_STAT_C_OVERCURRENT | USB_PORT_STAT_C_RESET)) =3D= =3D 0) { return EFI_SUCCESS; @@ -1728,17 +1730,29 @@ XhcPollPortStatusChange ( } else if ((PortState->PortStatus & USB_PORT_STAT_SUPER_SPEED) !=3D 0)= { Speed =3D EFI_USB_SPEED_SUPER; } - // - // Execute Enable_Slot cmd for attached device, initialize device cont= ext and assign device address. - // - SlotId =3D XhcRouteStringToSlotId (Xhc, RouteChart); - if ((SlotId =3D=3D 0) && ((PortState->PortChangeStatus & USB_PORT_STAT= _C_RESET) !=3D 0)) { - if (Xhc->HcCParams.Data.Csz =3D=3D 0) { - Status =3D XhcInitializeDeviceSlot (Xhc, ParentRouteChart, Port, R= outeChart, Speed); - } else { - Status =3D XhcInitializeDeviceSlot64 (Xhc, ParentRouteChart, Port,= RouteChart, Speed); + + do { + // + // Execute Enable_Slot cmd for attached device, initialize device co= ntext and assign device address. + // + SlotId =3D XhcRouteStringToSlotId (Xhc, RouteChart); + if ((SlotId =3D=3D 0) && ((PortState->PortChangeStatus & USB_PORT_ST= AT_C_RESET) !=3D 0)) { + if (Xhc->HcCParams.Data.Csz =3D=3D 0) { + Status =3D XhcInitializeDeviceSlot (Xhc, ParentRouteChart, Port,= RouteChart, Speed); + } else { + Status =3D XhcInitializeDeviceSlot64 (Xhc, ParentRouteChart, Por= t, RouteChart, Speed); + } } - } + + // + // According to the xHCI specification (section 4.6.5), "a USB Trans= action + // Error Completion Code for an Address Device Command may be due to= a Stall + // response from a device. Software should issue a Disable Slot Comm= and for + // the Device Slot then an Enable Slot Command to recover from this = error." + // Therefore, retry the device slot initialization if it fails due t= o a + // device error. + // + } while ((Status =3D=3D EFI_DEVICE_ERROR) && (Retries--)); } =20 return Status; diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h b/MdeModulePkg/Bus/Pc= i/XhciDxe/XhciSched.h index 2f1899502151..3f9cdb1c3609 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h @@ -11,6 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define _EFI_XHCI_SCHED_H_ =20 #define XHC_URB_SIG SIGNATURE_32 ('U', 'S', 'B', 'R') +#define XHC_INIT_DEVICE_SLOT_RETRIES 1 =20 // // Transfer types, used in URB to identify the transfer type --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#66566): https://edk2.groups.io/g/devel/message/66566 Mute This Topic: https://groups.io/mt/77749182/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-