From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.3434.1603328063860219673 for ; Wed, 21 Oct 2020 17:54:24 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=A+CcOBR5; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: hao.a.wu@intel.com) IronPort-SDR: JdZFuMN7DTg4zblXok1jOl7h/jamUGg4aC3lgK4/fF/E/ZkAsaOzpWwOiB9wRyVxl8VoG8tDT2 aBSvEnwVh++w== X-IronPort-AV: E=McAfee;i="6000,8403,9781"; a="167576164" X-IronPort-AV: E=Sophos;i="5.77,402,1596524400"; d="scan'208";a="167576164" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2020 17:54:21 -0700 IronPort-SDR: gq8nEqtZr37lloU9+70HrLLlMIwnWP0yg/8ei353ICYMXAl0KwAO41O35Csv5XfWQACqTp5wSj oQ502X5YuDdA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,402,1596524400"; d="scan'208";a="359696552" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by orsmga007.jf.intel.com with ESMTP; 21 Oct 2020 17:54:20 -0700 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 21 Oct 2020 17:54:19 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx603.amr.corp.intel.com (10.18.126.83) 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, 21 Oct 2020 17:54:19 -0700 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.41) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Wed, 21 Oct 2020 17:54:19 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bpMleC6ct97g/H4URbPvZUvktIk5lkmtt1nh9KwLsN2WZUPeFdzmi7b2LhrSey0S3qXLGlBkK5ZJ2BuQASgiLN45hbWjM4v3as+Xj/w1zQwmI2jHgpC41W/sWEZom7g+nISxzt3X9z6NFEaKnICTCzvyydS/gJkVjh3u6+yAn4eDTQ7kl6ZzjR4uaqWFmccyexgBsCKdVPM/2WFAQw3/6K8Nq6eUchW3d44f9SWcC6Cf5Ewo61CTxoRBeokCMB4FYS8iD52rydSBWgu0cDoGQWI9M0L3HS1hI9hd556QYVwifaLb4q+Xyfgjj4UlzLqmjhRVMT9L5CeqUxVUjkngDw== 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=n5xQzVl1Z3e8FbAkhc1usda6J13cZTL/54RCcAinrNE=; b=fWC7eBgFXSDctXP1THFKUqyFqSqshI6i+67Wnz4iRzK/NR1WeGmJ2/ni4M668giKaK1LePLZSPAREz/slx8o6x15HHYEKERI6A9+PVTCR3cYPeA6whWuH5inGv3HheBOWB/Z8jDYINUmpCAKvtt3Faszb0FdwVOB0P81p2kBb1QsaLVP3XZwtruR3nius/7cFRwZSWCuC4/7y3kuxupiLvOcjmDkUTsa3ACdCtR3/1hZUvS0Pv77+YvULCUUyFbCUBVimFyqSXt7tFwWC5NWa2OhH3fAh9UOjoJQBTs1U88eJRAIekKa+rh2Lm5AN7wztdwGvhNCIw0iC6ocgnddig== 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=n5xQzVl1Z3e8FbAkhc1usda6J13cZTL/54RCcAinrNE=; b=A+CcOBR5dDTT5ilWHd9CdFKdffakzDu+q20MTaZP0ESbzwFRnfGP3ugF5AqzoKAQOMzR9/sDzeokItRx+XtVZrQad9O0FogiGsQ9/NatMq18qKTIHoFnF9ZmP7uPT3e9VOZ4xA5cyvhUQEGZCiTlfnZ5W3LkEC0OxOcLtZbYIa0= Received: from BN8PR11MB3666.namprd11.prod.outlook.com (2603:10b6:408:8c::19) by BN7PR11MB2660.namprd11.prod.outlook.com (2603:10b6:406:b2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.25; Thu, 22 Oct 2020 00:54:18 +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, 22 Oct 2020 00:54:18 +0000 From: "Wu, Hao A" To: "devel@edk2.groups.io" , "jbrasen@nvidia.com" , "Luo, Heng" CC: "Ni, Ray" , Jon Hunter Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/XhciDxe: Retry device slot init on failure Thread-Topic: [edk2-devel] [PATCH] MdeModulePkg/XhciDxe: Retry device slot init on failure Thread-Index: AQHWp8EllGnyZlgxiEmc4jnJaMZE56miyweg Date: Thu, 22 Oct 2020 00:54:17 +0000 Message-ID: References: In-Reply-To: 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: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; 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: e88ab599-b7f9-478f-a72f-08d876250165 x-ms-traffictypediagnostic: BN7PR11MB2660: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: yeGBCt3HJ4xvT03TrdeL0v3LZnIeikwt4QuBY2xxXbno2bbjs2PO15eAfvocJ58YH+2AnRIIo3i8xNj+XB7ez4fGW3E92/Tlr+yxtDDsB7tJRhp34ezo37GYH4VDQkbMD9ksIKMilBC/J41oxm3N7CkTIoQf1iyfGKpQGtXXbhHyBWDoJQDSCw/0YGsOWX2tpDzrtuL14mZkpD+hjOlr7MDyhkec4OHL3nT/qlIxmQQvIMRtf4ku16P6zcDHJql026kLwkESLw1PXZhbB2th2FFKjewy6ddVzMuQMsGnWA+xTBpHPLQWOLgGGEh6YlES6RUiaqhkTwQV/rkd+5HKp1M4+Mx2Cni8SfnUC+yAEpmTRQn6sVBy5SbO8oyWomj5suVCvs2KAbxb6wEqBV5VAQ== 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)(136003)(376002)(39860400002)(346002)(366004)(396003)(76116006)(9686003)(83380400001)(5660300002)(4326008)(19627235002)(86362001)(33656002)(2906002)(52536014)(66946007)(55016002)(8936002)(71200400001)(66476007)(66556008)(6636002)(478600001)(66446008)(64756008)(316002)(26005)(6506007)(7696005)(54906003)(53546011)(110136005)(186003)(966005)(8676002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: y20LnhqVKfuNAZfF7COIInj0c0UD5yDnS7yK5+tMvpkSlbDm7X23cvikS+dpS4c5lZCSxwtIVXftVygzykSjWn3mf4m4Jhdd0bDXaeaxId67ZfCjWZrNoGozxyIWssJwVzU2IFp62nG7Eu81zNS+R7zLCL4M7Zo5j1SqYmTFZ6CYNcF4+0uqP/JAkKus6RfvVHloDolo8DbqQ5Nm1Hw8QuVtWLJjgm1DXuifDyx5Ir9kPa2fP0O3kawCVX6TpZibVk8bgUIEEJRB2QH1c/3QR5BmvkC2sTYC8YaGp82eDOgHZm7yU8rOV0PGrNGCN3RiSarRTD7nfaIrc6Zj9mITfSqM22VlUHEh/kHX9GNvj/9jJol9s0gqRYRDuuPwCCK5+/WLrSe5taFYU6/D3JDxhYdovooVlxiMEZ13aE+KZOG3H5c2zRQryBGpbZLtZ2y7cmk44z8XJ5QIZfW1sTngz9Y3z/zsR6jwekOygJuL/0aaAOOYZ/SQrMr+PIeUQulN94GekdsUWRPecN8KAEoweZLx0Tt8QPDjNCb12EE8mOiD9aEPQlhP4e/YgtoQ4D7Vw53gY+xi/x5nBqy4uZ5peIhrWTYtuvl26wqm/FIJugxZTnO1K/xNcbSc1vtA2TXbGUU7I9HiGl0Qro7GFQ4zMg== 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: e88ab599-b7f9-478f-a72f-08d876250165 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Oct 2020 00:54:17.9273 (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: oh9rrYFOSp6O6JHLffNlPp7ozU9NA3q4os9n9+ENflqACS3GC2ovVahXHzjhdip7rsjdW4vyzpr701ij76PsFw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR11MB2660 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 Hello Heng, It looks to me that the patch is addressing a similar issue you met on the= UpXtreme board mentioned in: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3007 Could you help to check if such retry during the slot initialization helps= for the USB device on your board? Thanks in advance. Best Regards, Hao Wu > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Jeff > Brasen > Sent: Wednesday, October 21, 2020 11:45 PM > To: devel@edk2.groups.io > Cc: Wu, Hao A ; Ni, Ray ; Jon > Hunter ; Jeff Brasen > Subject: [edk2-devel] [PATCH] 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 d= evice error. >=20 > Signed-off-by: Jeff Brasen > --- > MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 71 ++++++++++++++-------- > -- > 1 file changed, 42 insertions(+), 29 deletions(-) >=20 > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c > b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c > index 9cb115363c..1a16864205 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 1; >=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; > @@ -1739,40 +1741,51 @@ XhcPollPortStatusChange ( > RouteChart.Route.TierNum =3D ParentRouteChart.Route.TierNum += 1; > } >=20 > - SlotId =3D XhcRouteStringToSlotId (Xhc, RouteChart); > - if (SlotId !=3D 0) { > - if (Xhc->HcCParams.Data.Csz =3D=3D 0) { > - Status =3D XhcDisableSlotCmd (Xhc, SlotId); > - } else { > - Status =3D XhcDisableSlotCmd64 (Xhc, SlotId); > - } > - } > - > - if (((PortState->PortStatus & USB_PORT_STAT_ENABLE) !=3D 0) && > - ((PortState->PortStatus & USB_PORT_STAT_CONNECTION) !=3D 0)) { > - // > - // Has a device attached, Identify device speed after port is enabl= ed. > - // > - Speed =3D EFI_USB_SPEED_FULL; > - if ((PortState->PortStatus & USB_PORT_STAT_LOW_SPEED) !=3D 0) { > - Speed =3D EFI_USB_SPEED_LOW; > - } else if ((PortState->PortStatus & USB_PORT_STAT_HIGH_SPEED) !=3D = 0) { > - Speed =3D EFI_USB_SPEED_HIGH; > - } 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 c= ontext > and assign device address. > - // > + do { > SlotId =3D XhcRouteStringToSlotId (Xhc, RouteChart); > - if ((SlotId =3D=3D 0) && ((PortState->PortChangeStatus & > USB_PORT_STAT_C_RESET) !=3D 0)) { > + if (SlotId !=3D 0) { > if (Xhc->HcCParams.Data.Csz =3D=3D 0) { > - Status =3D XhcInitializeDeviceSlot (Xhc, ParentRouteChart, Port= , > RouteChart, Speed); > + Status =3D XhcDisableSlotCmd (Xhc, SlotId); > } else { > - Status =3D XhcInitializeDeviceSlot64 (Xhc, ParentRouteChart, Po= rt, > RouteChart, Speed); > + Status =3D XhcDisableSlotCmd64 (Xhc, SlotId); > } > } > - } > + > + if (((PortState->PortStatus & USB_PORT_STAT_ENABLE) !=3D 0) && > + ((PortState->PortStatus & USB_PORT_STAT_CONNECTION) !=3D 0)) { > + // > + // Has a device attached, Identify device speed after port is ena= bled. > + // > + Speed =3D EFI_USB_SPEED_FULL; > + if ((PortState->PortStatus & USB_PORT_STAT_LOW_SPEED) !=3D 0) { > + Speed =3D EFI_USB_SPEED_LOW; > + } else if ((PortState->PortStatus & USB_PORT_STAT_HIGH_SPEED) != =3D 0) { > + Speed =3D EFI_USB_SPEED_HIGH; > + } 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= 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, Po= rt, > RouteChart, Speed); > + } else { > + Status =3D XhcInitializeDeviceSlot64 (Xhc, ParentRouteChart, = Port, > RouteChart, Speed); > + } > + } > + } > + > + // > + // According to the xHCI specification (section 4.6.5), "a USB Tran= saction > + // Error Completion Code for an Address Device Command may be due t= o > a Stall > + // response from a device. Software should issue a Disable Slot Com= mand > for > + // the Device Slot then an Enable Slot Command to recover from this > error." > + // Therefore, retry the device slot initialization if it fails due = to a > + // device error. > + // > + } while ((Status =3D=3D EFI_DEVICE_ERROR) && (Retries--)); >=20 > return Status; > } > -- > 2.25.1 >=20 >=20 >=20 >=20 >=20