From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id EFBFFAC0A0C for ; Thu, 7 Sep 2023 02:59:52 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=xwty0oprrLp/sMO9etzeXKKCrIh9L+HbtbfU1dcgPSk=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1694055591; v=1; b=WNl7AES4TiNU3VMzJMoqg6q2rKzg5T7IFe5ZyXVL/e+pee11rg8dhdoY8DANpEiqjAhxM+i1 /OfSgcNDUxYmEG4VUsJnUYsmMCStuerqpYLiYFwHNbGwwmi4CsHQSTsT2DZ1y+91t6I+A1k/ooA XpvdMzgaF6dDR5ayid9QLpWU= X-Received: by 127.0.0.2 with SMTP id NclFYY7687511xrzn7AZhdvD; Wed, 06 Sep 2023 19:59:51 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web11.5454.1694055591103933166 for ; Wed, 06 Sep 2023 19:59:51 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10825"; a="377157946" X-IronPort-AV: E=Sophos;i="6.02,233,1688454000"; d="scan'208";a="377157946" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2023 19:59:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10825"; a="831965403" X-IronPort-AV: E=Sophos;i="6.02,233,1688454000"; d="scan'208";a="831965403" X-Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by FMSMGA003.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 06 Sep 2023 19:59:50 -0700 X-Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Wed, 6 Sep 2023 19:59:49 -0700 X-Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 6 Sep 2023 19:59:49 -0700 X-Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Wed, 6 Sep 2023 19:59:49 -0700 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.41) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.27; Wed, 6 Sep 2023 19:59:49 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FcVI4Nm4HamGYo83XG1gVIil3dfJohW5gtvaoTBZHXZ44+RyIvV3JqdbhwDe0N2eZxHhWtiwTDsIhvi32FvBIbHP6TwzUE8faKQTVfIchpqSa8DJfcwXLPd5c7Kkzg+XESII7kYLO6603wU5+zSP0kd/06Ey3zKSg5jD9onpY2a/9G7vW11nt1SZrqYi907RqQ1lj/+rn5tPcy+rN0Di2m0i/z/0dkj9D2Q7r8AcTnpXRk1PB0U7UmTrjZObDEE4jtFIYEJEIoMfvlgYS33Nc7ZMyiggv2wX0KRkUyPPm5g+aWEysdi1ypSFQf3voBS7YgGIP8F+P/7x4CPNyAuSIA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+bqdXOkjX8Luc7ZgSkA1n7t9WcY+3bGvPNDOcroMa5s=; b=Ra27uQ3ujLFsNYiNV/I33Yn3/zrVfA8Pl6C/CvJ87ewfElIquYj/o9VAvxEuYYvAhlsH5Y1aGmkVBT54AFdV8kMoNpMEKL98KVYMdpOxq2Jf/i/shlDDsiHvxdv+EOUGtbWcO1Ail/WhELkW5c054PfpU+zAAuTSmLSlN8LtTuTmHyK8s0o7T3zzwmBNF+Kg45yqxb3NGTdWnCUNnAS7OnbUDMcP690G3HMpOxG1ALLnW0Ue+JhfIK1nf1cNHYFY8b+9RRcUKhnUIyQeOSJOZpQ4rnLiaDzNDd3ra1/+ZuHd8lJ6v0goxrfICG6xNHGKMAPM2m/wTTBPJ+RwA8oHbw== 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 X-Received: from DM6PR11MB4025.namprd11.prod.outlook.com (2603:10b6:5:197::31) by SA2PR11MB5146.namprd11.prod.outlook.com (2603:10b6:806:116::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.36; Thu, 7 Sep 2023 02:59:41 +0000 X-Received: from DM6PR11MB4025.namprd11.prod.outlook.com ([fe80::38c3:ed7c:3562:2e18]) by DM6PR11MB4025.namprd11.prod.outlook.com ([fe80::38c3:ed7c:3562:2e18%4]) with mapi id 15.20.6745.035; Thu, 7 Sep 2023 02:59:40 +0000 From: "Wu, Hao A" To: "devel@edk2.groups.io" , "Henz, Patrick" Subject: Re: [edk2-devel] [PATCH v2] MdeModulePkg/XhciDxe: Use Performance Timer for XHCI Timeouts Thread-Topic: [edk2-devel] [PATCH v2] MdeModulePkg/XhciDxe: Use Performance Timer for XHCI Timeouts Thread-Index: AQHZzseBJIO8HXAamkWgXd40zbxjr7AOZHvggABS3cCAABj/gA== Date: Thu, 7 Sep 2023 02:59:40 +0000 Message-ID: References: <177B4AD1F8C3A6A2.8497@groups.io> In-Reply-To: Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM6PR11MB4025:EE_|SA2PR11MB5146:EE_ x-ms-office365-filtering-correlation-id: bc39f638-44ee-4295-9e4d-08dbaf4e7a89 x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: p57xgef2CelCntpQSWfuPISEKkc9lLPBYeDsmSWslg/wDBRC//RIbY8rj7yUAqsrC8g6lH7s0lRYbXTT0oQBfbiZRfh4vyKdtbPMq0jrZ/9DjZuxnxTMyKJT31/BF8Sk2IFDg8kHpHQarZX7PSoReO5oCyEjHb4Z+wWZ/Pa/mSxlpZntcJFgnc6wvkfSaTV/IYRDLQZzYsjpIMJmORn6uzTpodaLNSDhwUGPVX+bVxYKhbY+n68zb4LOa8gwABzlt4HoXDFje5guFM5r1iXD/Yt6t7FYisCXewRLS0/E+4zes8BuVzxOFK4OUEHYIId+nehtqGINUpZKFVJRWTTXqVEzL8MpZITT4rT+VpdCNKHfvZAuM20O4oXGNR7G7SX+igF/MHv8nH9zZK3zQLjkUGedSYQycULEtuK/4kxQaqpqqmZo9wvrR9D8678UtOt+2lSYTilYC1xzgVmXlINdOOAcqFRaCl99F9/0AD7Oqh2e6x00ErhPV9OoFQvNaKxGWYVppbI+MW++H5qDKsv0Lw3h2N3MkyIiP8DdVHO1NRiDuixbU84lSwIrhIe4jCBJOCxEUg1Blyi7987K1ywF7fPf0W+ySHnIMa1lan1VRODUT+sIeq6Do2lIZoNyGL/sPuqJ3cEkGPFIeg4EXXP3Gw== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?/wic12Ua6B6h2LNdWIZVEvZISIFsrEXh1ObXtupxf9X19fjs7GvUYaKulvhe?= =?us-ascii?Q?ZHz+RwASvL8R+Vc5zMwjIph4vTw7CszWw3h4wLEGCEhGF9wHQd4UNPXKj0yg?= =?us-ascii?Q?K0X7eXu4iPoneTITTU/F0Kt/ZnA2uRZewPsseOkZ6K3X5h4O2zzxUFT2Enux?= =?us-ascii?Q?b85srB3lohqqqVPSdRwdnj/5R81YRXhMtIPwWr/3VPjZIlM5toOhlHsSI7wG?= =?us-ascii?Q?A2co+CFSf8kPjMUJuUaAAa+ehTurGMWnUwBzwW6jO1pfL4IBARcDuPYFaiZe?= =?us-ascii?Q?45pkNhrB+xfwX58nZUxFLYHfl7cNOcTEjtL9wKCbZgYwqqhTeBUun29x65WC?= =?us-ascii?Q?cgH+jbBPTFmxaoyamcHGhkusreEidf8XYktK59dDTTIBQfBh42uqKSX6OWiQ?= =?us-ascii?Q?tmQ1chRH/URkPrtNHmnIljpVFhw1FHgHg4qG4Atsal2Wewrw9ki4kef8rPwS?= =?us-ascii?Q?ZNT1f3N84R4ckqoWouq9Bn/fvwNlp2Q6YsPhjcdmofyx8CpibiOITrHppRAa?= =?us-ascii?Q?SMBfOLumbEJCzks0RgEMHW+Qh6sM0krsZ3jp3FMgLITopiTE6QfjlxToAg/c?= =?us-ascii?Q?QXbltlj+Legw3/HuYNIbIroNh++oEHUoqk/Aoi4oRCAm0Hh8B8VAMEmpwFxp?= =?us-ascii?Q?6NKrazmyg7j2Yu+wOXfgn0Ka9+7UMUEQcqTlR16Y8F1B0AH5PHSltuGG0r64?= =?us-ascii?Q?TNKxZoadBsj47GQYqbqVTdt+pjndTXY4iI4WF3MpEqEsEooNGoYT5hXQxNJZ?= =?us-ascii?Q?4wmRa+9kagJKvKdqMc31zwYxxxi9gZGNIB0C+l98kgNreh9+CDYItHva3+vz?= =?us-ascii?Q?u2I66yvwkm6W+TnWKEo7s+kxe0kBfMuXlGauVfpk+ilBvdM01+lWlK+olYcy?= =?us-ascii?Q?HwSr7FHXRv9zxcWN7ahDJrjroCuPKpX7vKrBXLPEAKpWdPou0zpyTWFEjQ4x?= =?us-ascii?Q?vsioFCKAb7dUPFG4oC3CbSLSxyH6mU6ze19FZOChG8cf1CTuMqj290v0EY+j?= =?us-ascii?Q?33nDxhfzP8oNRwTSrFSsbdNYKVHRchMK7fIxmPH7tWu+L+yzWO2HgIlON9sx?= =?us-ascii?Q?vZj1fRZcSGriUMXvF9tmxMMtCaJ6rTmBzwOH6Jn7FZ3xJpJbXOxc8MY2KUmM?= =?us-ascii?Q?25O521AXwZlWMPRK+ajTXEU5O85lt2ctG4usL/7eTSdINdvRVMJgV3YPKPc/?= =?us-ascii?Q?azrI8O56jusgyYI13PVgVPERbCc3kbUN3iDXHpCdl+LlwHMN3IDYjzkflskc?= =?us-ascii?Q?hc7maHT/5KHFKyUbTz4ozOb3KHNb5mpU7aILnU33+FTIrRTRu2e8VUoEBZnv?= =?us-ascii?Q?fxPx/QIOH9BGZSWjrEPypg6IrEU34nuA0l6B31Yert0DMHafOU3P0F8LVZfl?= =?us-ascii?Q?icaXmAY+dkJDD8v5CAahdCbR6az9hOihymORGsqmOOj0QjON5KnUgi8ums7g?= =?us-ascii?Q?CFfBWeGILCOEbyh3J6/IzQtdGQz9zPr1aAjg/8wNNN8to3OpUHDVFObDNqCv?= =?us-ascii?Q?9n4ccH33zSimSVdaUspIUrEQeDYeyvL3K+lrS4HTfEvmTpMIqUBaynAuQw?= =?us-ascii?Q?=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB4025.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc39f638-44ee-4295-9e4d-08dbaf4e7a89 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Sep 2023 02:59:40.1044 (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: C2K9uGMMO5eTdTihuSg/m+UM2n6WUyxNzVqXXLNNzWiAaKEAEuTDxyLm7wXPGWEnHzSfWXnbR2d4jmBUDYawGw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5146 X-OriginatorOrg: intel.com Precedence: Bulk List-Subscribe: List-Help: 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,hao.a.wu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 9NlAfMErJd9hQwuhKSx1h48fx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=WNl7AES4; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Sorry, I found that there is a build failure for the proposed change: PR - https://github.com/tianocore/edk2/pull/4796 Details: https://dev.azure.com/tianocore/edk2-ci/_build/results?buildId=3D101097&vie= w=3Dlogs&j=3D2dc6585a-9807-582d-5eb8-65e26db2b1d0&t=3Dfe91d259-3a7c-5e73-48= 92-c865ef48cb16 ERROR - Linker #2001 from XhciDxe.lib(XhciSched.obj) : unresolved external = symbol __allmul ERROR - Linker #2001 from XhciDxe.lib(XhciReg.obj) : unresolved external sy= mbol __allmul ERROR - Linker #1120 from d:\a\1\s\Build\OvmfIa32\NOOPT_VS2019\IA32\MdeModu= lePkg\Bus\Pci\XhciDxe\XhciDxe\DEBUG\XhciDxe.dll : fatal 1 unresolved extern= als I think we need to update "(UINT64)Timeout * XHC_1_MILLISECOND" by using Ba= seLib API MultU64x32(). Could you help to update the patch and check if it can pass the CI builds, = thanks. Best Regards, Hao Wu > -----Original Message----- > From: Wu, Hao A > Sent: Thursday, September 7, 2023 9:28 AM > To: devel@edk2.groups.io; Henz, Patrick > Subject: RE: [edk2-devel] [PATCH v2] MdeModulePkg/XhciDxe: Use > Performance Timer for XHCI Timeouts >=20 > Sorry for the late response. > Reviewed-by: Hao A Wu >=20 > Best Regards, > Hao Wu >=20 > > -----Original Message----- > > From: devel@edk2.groups.io On Behalf Of Henz, > > Patrick > > Sent: Thursday, September 7, 2023 4:37 AM > > To: devel@edk2.groups.io > > Subject: Re: [edk2-devel] [PATCH v2] MdeModulePkg/XhciDxe: Use > > Performance Timer for XHCI Timeouts > > > > I sent this patch out a few weeks ago now but haven't seen a reply, > > just checking in to make sure it didn't get missed. > > > > Thanks, > > Patrick Henz > > > > -----Original Message----- > > From: devel@edk2.groups.io On Behalf Of Henz, > > Patrick > > Sent: Monday, August 14, 2023 10:52 AM > > To: devel@edk2.groups.io > > Cc: Henz, Patrick > > Subject: [edk2-devel] [PATCH v2] MdeModulePkg/XhciDxe: Use Performance > > Timer for XHCI Timeouts > > > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2948 > > > > XhciDxe uses the timer functionality provided by the boot services > > table to detect timeout conditions. This breaks the driver's > > ExitBootServices call back, as CoreExitBootServices halts the timer > > before signaling the ExitBootServices event. If the host controller > > fails to halt in the call back, the timeout condition will never occur > > and the boot gets stuck in an indefinite spin loop. Use the free > > running timer provided by TimerLib to calculate timeouts, avoiding the > potential hang. > > > > Signed-off-by: Patrick Henz > > Reviewed-by: > > --- > > MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c | 56 +++++++++++++++++++ > > MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h | 22 ++++++++ > > MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf | 2 + > > MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c | 67 +++++++++-------------- > > MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 68 > > +++++++++--------------- > > 5 files changed, 129 insertions(+), 86 deletions(-) > > > > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c > > b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c > > index 62682dd27c..1dcbe20512 100644 > > --- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c > > +++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c > > @@ -1,6 +1,7 @@ > > /** @file > > The XHCI controller driver. > > > > +(C) Copyright 2023 Hewlett Packard Enterprise Development LP
> > Copyright (c) 2011 - 2022, Intel Corporation. All rights > > reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > @@ -2294,3 +2295,58 @@ XhcDriverBindingStop ( > > > > return EFI_SUCCESS; > > } > > + > > +/** > > + Computes and returns the elapsed time in nanoseconds since > > + PreviousTick. The value of PreviousTick is overwritten with the > > + current performance counter value. > > + > > + @param PreviousTick Pointer to PreviousTick count. > > + @return The elapsed time in nanoseconds since PreviousCount. > > + PreviousCount is overwritten with the current performance > > + counter value. > > +**/ > > +UINT64 > > +XhcGetElapsedTime ( > > + IN OUT UINT64 *PreviousTick > > + ) > > +{ > > + UINT64 StartValue; > > + UINT64 EndValue; > > + UINT64 CurrentTick; > > + UINT64 Delta; > > + > > + GetPerformanceCounterProperties (&StartValue, &EndValue); > > + > > + CurrentTick =3D GetPerformanceCounter (); > > + > > + // > > + // Determine if the counter is counting up or down // if > > + (StartValue < EndValue) { > > + // > > + // Counter counts upwards, check for an overflow condition > > + // > > + if (*PreviousTick > CurrentTick) { > > + Delta =3D (EndValue - *PreviousTick) + CurrentTick; > > + } else { > > + Delta =3D CurrentTick - *PreviousTick; > > + } > > + } else { > > + // > > + // Counter counts downwards, check for an underflow condition > > + // > > + if (*PreviousTick < CurrentTick) { > > + Delta =3D (StartValue - CurrentTick) + *PreviousTick; > > + } else { > > + Delta =3D *PreviousTick - CurrentTick; > > + } > > + } > > + > > + // > > + // Set PreviousTick to CurrentTick > > + // > > + *PreviousTick =3D CurrentTick; > > + > > + return GetTimeInNanoSecond (Delta); } > > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h > > b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h > > index ca223bd20c..77feb66647 100644 > > --- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h > > +++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h > > @@ -2,6 +2,7 @@ > > > > Provides some data structure definitions used by the XHCI host > > controller driver. > > > > +(C) Copyright 2023 Hewlett Packard Enterprise Development LP
> > Copyright (c) 2011 - 2017, Intel Corporation. All rights > > reserved.
Copyright (c) Microsoft Corporation.
> > SPDX-License-Identifier: BSD-2-Clause-Patent @@ -26,6 +27,7 @@ SPDX- > > License-Identifier: BSD-2-Clause-Patent #include > > #include #include > > > > +#include > > > > #include > > > > @@ -37,6 +39,10 @@ typedef struct _USB_DEV_CONTEXT > USB_DEV_CONTEXT; > > #include "ComponentName.h" > > #include "UsbHcMem.h" > > > > +// > > +// Converts a count from microseconds to nanoseconds // #define > > +XHC_MICROSECOND_TO_NANOSECOND(Time) ((UINT64)(Time) * 1000) > > // > > // The unit is microsecond, setting it as 1us. > > // > > @@ -720,4 +726,20 @@ XhcAsyncIsochronousTransfer ( > > IN VOID *Context > > ); > > > > +/** > > + Computes and returns the elapsed time in nanoseconds since > > + PreviousTick. The value of PreviousTick is overwritten with the > > + current performance counter value. > > + > > + @param PreviousTick Pointer to PreviousTick count. > > + before calling this function. > > + @return The elapsed time in nanoseconds since PreviousCount. > > + PreviousCount is overwritten with the current performance > > + counter value. > > +**/ > > +UINT64 > > +XhcGetElapsedTime ( > > + IN OUT UINT64 *PreviousTick > > + ); > > + > > #endif > > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf > > b/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf > > index 5865d86822..18ef87916a 100644 > > --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf > > +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf > > @@ -3,6 +3,7 @@ > > # It implements the interfaces of monitoring the status of all ports > > and transferring # Control, Bulk, Interrupt and Isochronous requests > > to those attached usb LS/FS/HS/SS devices. > > # > > +# (C) Copyright 2023 Hewlett Packard Enterprise Development LP
> > # Copyright (c) 2011 - 2018, Intel Corporation. All rights > > reserved.
# # > > SPDX-License-Identifier: BSD-2-Clause-Patent @@ -54,6 +55,7 @@ > > BaseMemoryLib > > DebugLib > > ReportStatusCodeLib > > + TimerLib > > > > [Guids] > > gEfiEventExitBootServicesGuid ## SOMETIMES_CONSUMES = ## > > Event > > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c > > b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c > > index 5700fc5fb8..07e57772b6 100644 > > --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c > > +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c > > @@ -2,6 +2,7 @@ > > > > The XHCI register operation routines. > > > > +(C) Copyright 2023 Hewlett Packard Enterprise Development LP
> > Copyright (c) 2011 - 2017, Intel Corporation. All rights > > reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > @@ -417,15 +418,14 @@ XhcClearOpRegBit ( > > Wait the operation register's bit as specified by Bit > > to become set (or clear). > > > > - @param Xhc The XHCI Instance. > > - @param Offset The offset of the operation register. > > - @param Bit The bit of the register to wait for. > > - @param WaitToSet Wait the bit to set or clear. > > - @param Timeout The time to wait before abort (in mil= lisecond, > > ms). > > + @param Xhc The XHCI Instance. > > + @param Offset The offset of the operation register. > > + @param Bit The bit of the register to wait for. > > + @param WaitToSet Wait the bit to set or clear. > > + @param Timeout The time to wait before abort (in millisecond, = ms). > > > > - @retval EFI_SUCCESS The bit successfully changed by host > controller. > > - @retval EFI_TIMEOUT The time out occurred. > > - @retval EFI_OUT_OF_RESOURCES Memory for the timer event could not > > be allocated. > > + @retval EFI_SUCCESS The bit successfully changed by host controller= . > > + @retval EFI_TIMEOUT The time out occurred. > > > > **/ > > EFI_STATUS > > @@ -437,54 +437,35 @@ XhcWaitOpRegBit ( > > IN UINT32 Timeout > > ) > > { > > - EFI_STATUS Status; > > - EFI_EVENT TimeoutEvent; > > - > > - TimeoutEvent =3D NULL; > > + UINT64 TimeoutTime; > > + UINT64 ElapsedTime; > > + UINT64 TimeDelta; > > + UINT64 CurrentTick; > > > > if (Timeout =3D=3D 0) { > > return EFI_TIMEOUT; > > } > > > > - Status =3D gBS->CreateEvent ( > > - EVT_TIMER, > > - TPL_CALLBACK, > > - NULL, > > - NULL, > > - &TimeoutEvent > > - ); > > - > > - if (EFI_ERROR (Status)) { > > - goto DONE; > > - } > > - > > - Status =3D gBS->SetTimer ( > > - TimeoutEvent, > > - TimerRelative, > > - EFI_TIMER_PERIOD_MILLISECONDS (Timeout) > > - ); > > - > > - if (EFI_ERROR (Status)) { > > - goto DONE; > > - } > > + TimeoutTime =3D XHC_MICROSECOND_TO_NANOSECOND > ((UINT64)Timeout > > * > > + XHC_1_MILLISECOND); ElapsedTime =3D 0; CurrentTick =3D > > + GetPerformanceCounter (); > > > > do { > > if (XHC_REG_BIT_IS_SET (Xhc, Offset, Bit) =3D=3D WaitToSet) { > > - Status =3D EFI_SUCCESS; > > - goto DONE; > > + return EFI_SUCCESS; > > } > > > > gBS->Stall (XHC_1_MICROSECOND); > > - } while (EFI_ERROR (gBS->CheckEvent (TimeoutEvent))); > > - > > - Status =3D EFI_TIMEOUT; > > + TimeDelta =3D XhcGetElapsedTime (&CurrentTick); > > + // Ensure that ElapsedTime is always incremented to avoid > > + indefinite > > hangs > > + if (TimeDelta =3D=3D 0) { > > + TimeDelta =3D XHC_MICROSECOND_TO_NANOSECOND > > (XHC_1_MICROSECOND); > > + } > > > > -DONE: > > - if (TimeoutEvent !=3D NULL) { > > - gBS->CloseEvent (TimeoutEvent); > > - } > > + ElapsedTime +=3D TimeDelta; > > + } while (ElapsedTime < TimeoutTime); > > > > - return Status; > > + return EFI_TIMEOUT; > > } > > > > /** > > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c > > b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c > > index 53421e64a8..7d4b7a769d 100644 > > --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c > > +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c > > @@ -2,6 +2,7 @@ > > > > XHCI transfer scheduling routines. > > > > +(C) Copyright 2023 Hewlett Packard Enterprise Development LP
> > Copyright (c) 2011 - 2020, Intel Corporation. All rights > > reserved.
Copyright (c) Microsoft Corporation.
Copyright (C) > > 2022 Advanced Micro Devices, Inc. All rights reserved.
@@ -1276,15 > +1277,14 @@ EXIT: > > /** > > Execute the transfer by polling the URB. This is a synchronous opera= tion. > > > > - @param Xhc The XHCI Instance. > > - @param CmdTransfer The executed URB is for cmd transfer = or not. > > - @param Urb The URB to execute. > > - @param Timeout The time to wait before abort, in mil= lisecond. > > + @param Xhc The XHCI Instance. > > + @param CmdTransfer The executed URB is for cmd transfer or no= t. > > + @param Urb The URB to execute. > > + @param Timeout The time to wait before abort, in millisec= ond. > > > > - @return EFI_DEVICE_ERROR The transfer failed due to transfer e= rror. > > - @return EFI_TIMEOUT The transfer failed due to time out. > > - @return EFI_SUCCESS The transfer finished OK. > > - @retval EFI_OUT_OF_RESOURCES Memory for the timer event could not > > be allocated. > > + @return EFI_DEVICE_ERROR The transfer failed due to transfer error. > > + @return EFI_TIMEOUT The transfer failed due to time out. > > + @return EFI_SUCCESS The transfer finished OK. > > > > **/ > > EFI_STATUS > > @@ -1299,12 +1299,14 @@ XhcExecTransfer ( > > UINT8 SlotId; > > UINT8 Dci; > > BOOLEAN Finished; > > - EFI_EVENT TimeoutEvent; > > + UINT64 TimeoutTime; > > + UINT64 ElapsedTime; > > + UINT64 TimeDelta; > > + UINT64 CurrentTick; > > BOOLEAN IndefiniteTimeout; > > > > Status =3D EFI_SUCCESS; > > Finished =3D FALSE; > > - TimeoutEvent =3D NULL; > > IndefiniteTimeout =3D FALSE; > > > > if (CmdTransfer) { > > @@ -1322,34 +1324,14 @@ XhcExecTransfer ( > > > > if (Timeout =3D=3D 0) { > > IndefiniteTimeout =3D TRUE; > > - goto RINGDOORBELL; > > - } > > - > > - Status =3D gBS->CreateEvent ( > > - EVT_TIMER, > > - TPL_CALLBACK, > > - NULL, > > - NULL, > > - &TimeoutEvent > > - ); > > - > > - if (EFI_ERROR (Status)) { > > - goto DONE; > > } > > > > - Status =3D gBS->SetTimer ( > > - TimeoutEvent, > > - TimerRelative, > > - EFI_TIMER_PERIOD_MILLISECONDS (Timeout) > > - ); > > - > > - if (EFI_ERROR (Status)) { > > - goto DONE; > > - } > > - > > -RINGDOORBELL: > > XhcRingDoorBell (Xhc, SlotId, Dci); > > > > + TimeoutTime =3D XHC_MICROSECOND_TO_NANOSECOND > ((UINT64)Timeout > > * > > + XHC_1_MILLISECOND); ElapsedTime =3D 0; CurrentTick =3D > > + GetPerformanceCounter (); > > + > > do { > > Finished =3D XhcCheckUrbResult (Xhc, Urb); > > if (Finished) { > > @@ -1357,22 +1339,22 @@ RINGDOORBELL: > > } > > > > gBS->Stall (XHC_1_MICROSECOND); > > - } while (IndefiniteTimeout || EFI_ERROR (gBS->CheckEvent > > (TimeoutEvent))); > > + TimeDelta =3D XhcGetElapsedTime (&CurrentTick); > > + // Ensure that ElapsedTime is always incremented to avoid > > + indefinite > > hangs > > + if (TimeDelta =3D=3D 0) { > > + TimeDelta =3D XHC_MICROSECOND_TO_NANOSECOND > > (XHC_1_MICROSECOND); > > + } > > > > -DONE: > > - if (EFI_ERROR (Status)) { > > - Urb->Result =3D EFI_USB_ERR_NOTEXECUTE; > > - } else if (!Finished) { > > + ElapsedTime +=3D TimeDelta; > > + } while (IndefiniteTimeout || ElapsedTime < TimeoutTime); > > + > > + if (!Finished) { > > Urb->Result =3D EFI_USB_ERR_TIMEOUT; > > Status =3D EFI_TIMEOUT; > > } else if (Urb->Result !=3D EFI_USB_NOERROR) { > > Status =3D EFI_DEVICE_ERROR; > > } > > > > - if (TimeoutEvent !=3D NULL) { > > - gBS->CloseEvent (TimeoutEvent); > > - } > > - > > return Status; > > } > > > > -- > > 2.34.1 > > > > > > > > > > > > > > > > > >=20 > > -=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 (#108356): https://edk2.groups.io/g/devel/message/108356 Mute This Topic: https://groups.io/mt/100739508/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-