From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.2075.1603933413341864958 for ; Wed, 28 Oct 2020 18:03:33 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=Dm6WdYH8; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: hao.a.wu@intel.com) IronPort-SDR: FT8HP22AnRGZGGFyov5pDnc+YX9N7jIFzDfZTScmHHqhimz87FjeErJNPoImEawVyLYkbEn2XW ULZyJ+qr6Bng== X-IronPort-AV: E=McAfee;i="6000,8403,9788"; a="147643144" X-IronPort-AV: E=Sophos;i="5.77,428,1596524400"; d="scan'208";a="147643144" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2020 18:03:30 -0700 IronPort-SDR: lo9BXgSDgxgW6BTbbysJXdMBqA4LoU4O5Izbq+M9r/TM25O2L7lEvZfFiU9M6JEVk0a+rPb1gV Q8HecX+0GHaA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,428,1596524400"; d="scan'208";a="468945766" Received: from orsmsx604.amr.corp.intel.com ([10.22.229.17]) by orsmga004.jf.intel.com with ESMTP; 28 Oct 2020 18:03:28 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 28 Oct 2020 18:03:27 -0700 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 28 Oct 2020 18:03:27 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 28 Oct 2020 18:03:27 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.173) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Wed, 28 Oct 2020 18:03:26 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mjg3CFNTsJmLGpMGrX333NppRm2f/fZVEX5zbulQ6UC7Szrt6PK6vtaSgc6klk1lAWU+t6iO4ODCsWEsAUTtrrhEuWjRPdFDt4Kdj9RvGEt4DWrBG2hgV+OBNthkeaFIhw7GvdEnJnkaMYzXR7d1xQ/Z65SwNcHWrHjxRqTeCC176cbYgf6zq/NNKNtiCcRgx5lEmK3BnfZlDsKiIu0iWG4veNkRdgUwnNUsO0sCmRe0SqxFzM+kQD3F583FQZPThP5Evn8exEeNPI9XTzxHBSJgJxmbH+Z2qARkZUd58fogebMAPNe7KXUyiWAWi4PHwCi9j7g9zlNpOchP6CIpqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0gSECZIF092zKux42zkdZQ1RThM9CImkeXIZNVzc6y0=; b=U1sBNPP4Ji9RIoOI9YtSQDpDv5+JBQw+T/aOdpoG/OExUiSbwR3nkmJqCeWuT7tc0i7CguVw6fcJBnR51IwA3KspCqvhMsA0myD+elvLlSvqG+Sw7FobXkVQklwKDCb9WB+7mbWRITZ3k2++BjHHQTe9XJAJHi2xcrOZlHq4OieLYlzCFL7sAk5TdiJeWOg/eA7hmpRxbswJiZdl4W8ETnB/YWGgsXBUMTrBRugfnmPu4UD9rM0CPP/2Dxt8Lon6CEnimxpvdVTiHtuR7jvc4+PT/UPY+hw1GvhXwLBWgYINvtzfbwA4arZmLXXLbyI6HQAomxsjhRrFDNtXh5ycQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0gSECZIF092zKux42zkdZQ1RThM9CImkeXIZNVzc6y0=; b=Dm6WdYH85BqnbYLq797l3PSQnEugtguKZm+sg/LXpnax4hzAtYAQr6S0UhaNOVMIGkPDZ1wIhzLNIDmA3Q7vGnxwn03FVcjThlNUi/ZFmOz9LQJYdyxNfRUO94/XR2iMH8SAuPWQjaEDoWbXb93+55VqclgKFU2mp0ZRCEkCtHs= Received: from BN8PR11MB3666.namprd11.prod.outlook.com (2603:10b6:408:8c::19) by BN6PR11MB1714.namprd11.prod.outlook.com (2603:10b6:404:47::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.24; Thu, 29 Oct 2020 01:03:22 +0000 Received: from BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::c123:faac:1da3:f807]) by BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::c123:faac:1da3:f807%5]) with mapi id 15.20.3477.028; Thu, 29 Oct 2020 01:03:22 +0000 From: "Wu, Hao A" To: Jon Hunter , Jeff Brasen , "devel@edk2.groups.io" CC: "Luo, Heng" , "Ni, Ray" Subject: Re: [PATCH v3 1/1] MdeModulePkg/XhciDxe: Retry device slot init on failure Thread-Topic: [PATCH v3 1/1] MdeModulePkg/XhciDxe: Retry device slot init on failure Thread-Index: AQHWrU6qj9zXY/HJTkmuPLgnbg7ADamtw2Ng Date: Thu, 29 Oct 2020 01:03:22 +0000 Message-ID: References: <5a3b90de7f0c824e1a2c29ce06592b263e4c760e.1603905582.git.jbrasen@nvidia.com> In-Reply-To: <5a3b90de7f0c824e1a2c29ce06592b263e4c760e.1603905582.git.jbrasen@nvidia.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: nvidia.com; dkim=none (message not signed) header.d=none;nvidia.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.218] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: c1efed6f-3380-498a-3fa7-08d87ba66ec1 x-ms-traffictypediagnostic: BN6PR11MB1714: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: yChspPd5GMLtTd+JFn3UUa+lxUmr7npdQ5QqosMekksYQrC9lTUZkmZw/OyCwk6v2nRK/fwUvm8CNV/23OJhZRLNYjfigN+s5XqysOUi+HD2Zad21FGdcHBCBPhAxsNpA3mP70WG0cpTVFBLK+C+BZ8vjlba7rORpfPcF5o8H7caJ4QDjw1mAtYLYHcSfPt3I9NleIyB+yWDI1Hr1y6qQR1xmYHWDDPNi4peIKpcclHdQzFjKtGSzPS+Dl5yg66Xgib1OGS6LMIzX7FeaLU4LBSOsI4kco2a8tWWHK8aUJRVJNQsMkFHKxN1X27/JwUPDEsYKonYsW306p5Q1IoaAg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR11MB3666.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(136003)(346002)(39860400002)(396003)(366004)(52536014)(4326008)(86362001)(53546011)(5660300002)(71200400001)(76116006)(8676002)(66556008)(110136005)(107886003)(6506007)(7696005)(66446008)(33656002)(186003)(64756008)(66946007)(66476007)(26005)(19627235002)(478600001)(54906003)(9686003)(2906002)(55016002)(83380400001)(316002)(8936002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: p4RaSoKaShYIqai9BduhDd4EJ8vd4trNP1YNosVxoSAVsbc5yHpAKL036sXBir0/zQ5cP40QZ0C/djDDUXkv8X+Nn52Tshmrb4GhHzFYuGqIn4BsLir2J9WdEt852FpfiyCguxfDhuPLHMeanynmBQu+bNTCc/6eLTGmoinSgJqVpGGSfIyKkzqhAjyRU1ktm6d0buokMwCp6Ytv5QkahpzBzZswrwxOE1Sy1+hU6K2GLUlfLDWlTiWYS3zR2pCX5/AEuB55XAga+mITsxhX3EgY7Q/xBgFwoY8fw0hr0y201VFSIEA4J9PpkaDeOFuAdwhk1Dfj4eLRZ0r2FBHWITWgQ38dwTJBruAxbkAVRVRLZ9W9kjr+Epn9gIX4Q4lIguqn/qb9Ri4CpX3Mio2NeFhB65svTLzkIXvFDp+9+3Endl7g3d0hJ7z2Mqr1jZCaicrRkuM4CWQtwaYRGcyB16Px1bzAkwfLVDE86JkOIq7DLXLhwroi3ESlc2u2k4mNPvOPZ5E2uFW1WOT6XmbZISaDVl84OAVpElaD76TyJpBzgviJuVmPlOigfRsWXTEom97JXhj6xx3zr7WoO8TerIXcUQ1Pz2xBJWJGwKGQLsFXl81p8e8azyvX2mI3uRPrYIwRhFMO7YJV1jdfnz6wHA== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN8PR11MB3666.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c1efed6f-3380-498a-3fa7-08d87ba66ec1 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Oct 2020 01:03:22.4452 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: YWZLpifalpg8V1XYfQ63RQVvY/69ndr3LG7vAzelKk/bGDAF83+OAx7IY+C7JgCiMvUF8yOLJ2Pi75jj32Lq9w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1714 Return-Path: hao.a.wu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Jeff Brasen > Sent: Thursday, October 29, 2020 1:20 AM > To: devel@edk2.groups.io > Cc: Wu, Hao A ; Luo, Heng ; Ni, > Ray ; Jon Hunter ; Jeff Brasen > > Subject: [PATCH v3 1/1] MdeModulePkg/XhciDxe: Retry device slot init on > failure >=20 > From: Jon Hunter >=20 > 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. >=20 > According the the xHCI specification (section 4.6.5) ... >=20 > "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." >=20 > To fix this, retry the device slot initialization if it fails due to a de= vice error. >=20 > Change was verified using a superspeed mass storage device that was > occasionally failing to enumerate in UEFI. With this change this failure = to > enumerate was resolved. This failure was also only seen in UEFI and not i= n > the OS. >=20 > 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(-) >=20 > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h > b/MdeModulePkg/Bus/Pci/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/Pci/XhciDxe/XhciSched.c > index 00e9cc63d63e..dc36945962a0 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_PORT_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 co= ntext > 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, > RouteChart, Speed); > - } else { > - Status =3D XhcInitializeDeviceSlot64 (Xhc, ParentRouteChart, Por= t, > RouteChart, Speed); > + > + do { > + // > + // Execute Enable_Slot cmd for attached device, initialize device = context > 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, Por= t, > RouteChart, Speed); > + } else { > + Status =3D XhcInitializeDeviceSlot64 (Xhc, ParentRouteChart, P= ort, > RouteChart, Speed); > + } > } > - } > + > + // > + // According to the xHCI specification (section 4.6.5), "a USB Tra= nsaction > + // Error Completion Code for an Address Device Command may be due > to a Stall > + // response from a device. Software should issue a Disable Slot > Command for > + // the Device Slot then an Enable Slot Command to recover from thi= s > error." > + // Therefore, retry the device slot initialization if it fails due= to a > + // device error. > + // > + } while ((Status =3D=3D EFI_DEVICE_ERROR) && (Retries-- !=3D 0)); Thanks Jon and Jeff, Patch looks good to me: Reviewed-by: Hao A Wu I will wait a couple of days to see if there is any comment from others bef= ore merging the patch. Best Regards, Hao Wu > } >=20 > return Status; > -- > 2.25.1