From nobody Sun May 19 00:17:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+66662+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+66662+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=nvidia.com ARC-Seal: i=1; a=rsa-sha256; t=1603814408; cv=none; d=zohomail.com; s=zohoarc; b=Elm8VrJCxA7bY7bbENu7nH46k6NYKy9F2KA3s/5RTKEH1eLnHZzL+ZrTVWpGiFlnhceiuAChTzyFybw3S+q0BCl1d05ueYVJxxHZUx2CsQAJlpKMhXZB5bEXmbShAdiE3MCNMyOmWVjeQSa5Sk1G8asj1ABRkKuXKv1xdsZ80Z4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603814408; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=vk+XLCokFaCLKkUPt/DPYBtk6Sd/H7mhqD6au778rTs=; b=gRyr6WeWyqzOElDMd3Z8kJdC0FgXszRxSnNpJaB+YYySne/B+8YxXpBfXoN7JFf2cBrk4kKSUN2jU36XSgjIks5yEm2ns5U3+8DPZMk+WmduaLCWjs6d5/hujtzqw/ckemfKru4K6Wu/QIu73yQfv4XIjfQz87C7DcWf2x239GE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+66662+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1603814408754167.63886365012547; Tue, 27 Oct 2020 09:00:08 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Vu0NYY1788612xPF0yedqElY; Tue, 27 Oct 2020 09:00:07 -0700 X-Received: from hqnvemgate25.nvidia.com (hqnvemgate25.nvidia.com [216.228.121.64]) by mx.groups.io with SMTP id smtpd.web11.922.1603814407289362734 for ; Tue, 27 Oct 2020 09:00:07 -0700 X-Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Tue, 27 Oct 2020 09:00:11 -0700 X-Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 27 Oct 2020 16:00:06 +0000 X-Received: from jbrasen-ux.nvidia.com (10.124.1.5) by mail.nvidia.com (172.20.187.18) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Tue, 27 Oct 2020 16:00:05 +0000 From: "Jeff Brasen" To: CC: , , , Jon Hunter , Jeff Brasen Subject: [edk2-devel] [PATCH v2 ] MdeModulePkg/XhciDxe: Retry device slot init on failure Date: Tue, 27 Oct 2020 10:00:04 -0600 Message-ID: MIME-Version: 1.0 X-NVConfidentiality: public 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,jbrasen@nvidia.com X-Gm-Message-State: MBjLLjPKoiMU0W2mrc4MyeXox1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1603814407; bh=FIr1XuZ7qlGDE/Y+dxDKv9VHumez3gDR1bmDv6cG1k4=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=LZwv5iVRQ73uSLO/YqGtjwLtmxwPVuUUHu9Voy8J8zcdaor1GTeCScdp21QRLzA9Y/V kx/PA+kEHfNlvcDhENRIUKmNHUBTquTw3tB5eJ1wd0SYlmcoDdYKrq80eNDN95d0SbMji PQ0RMsC8d334YMRnvDTU+iFPnthg7Vamh0s= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Jon Hunter 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 Signed-off-by: Jeff Brasen --- MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h | 1 + MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 34 +++++++++++++++++------- 2 files changed, 25 insertions(+), 10 deletions(-) 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 diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/Pc= i/XhciDxe/XhciSched.c index 00e9cc63d63e..77664940a791 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c @@ -1717,9 +1717,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; @@ -1761,17 +1763,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; --=20 2.25.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 (#66662): https://edk2.groups.io/g/devel/message/66662 Mute This Topic: https://groups.io/mt/77841618/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-