From nobody Tue May 14 20:19:22 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+110434+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+110434+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1698771131; cv=none; d=zohomail.com; s=zohoarc; b=MC4yp7zqGJLgGis+bYgZ0djPEB5vf+RUxr807+Y5k33OL/mR15+wQc6B4ERHYu6CKd1OO0bTb2yyPmJtjF3y5Q1CxbOJrgbLemqiANrTYIY2G+AzPlqxYZXuqVy/T6JmVGFCxrM9WpMwcGOEfJgeNsYQ6G3ogu19qrE55PnOlt8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698771131; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=37IJHXIL0ykok+TI0ZeKSUuUFNTeDaRpBDML0z+nxfo=; b=QsWGc5rSXmI1UEiqCniwTnIb8KXM0IsOtkHcI78vSuFPa9a70VrbhNTnfoQg50wiVwjE4g5fDaXyfhtI8R1veNTBBL6hwkwIYa0Fr8r34qotybqK2RVUyDBQR/xDtCNdmg68Shff06U3iYTaAtGSrcN5McOEOHytdeD4Xy80+Xs= 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+110434+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 169877113166339.744509130062966; Tue, 31 Oct 2023 09:52:11 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=KmlPd1rrzVng51mqDC+nRB4an1LC9ReBbGSxsNhAn7M=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1698771131; v=1; b=hRtxChcWFf6fH4hXI2UIzNQImovPNbDwAwn/JZBtrHjZKUEOYzxaOKd9G56bVsuWskaldxdC MNrgO/cdrCrjkVZ+Kr7F2ZstPiloywn1TYSCRp54U+DxNCs99/kgiU2CScUUwwFh0hx7I9w5q6a CedU8Y9jNpN9niXDVs62saHw= X-Received: by 127.0.0.2 with SMTP id 7gFUYY1788612xI1e4aMhNf6; Tue, 31 Oct 2023 09:52:11 -0700 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web10.644.1698771110473229646 for ; Tue, 31 Oct 2023 09:52:10 -0700 X-Received: from pps.filterd (m0150242.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39VFG6RN010311; Tue, 31 Oct 2023 16:51:40 GMT X-Received: from p1lg14881.it.hpe.com ([16.230.97.202]) by mx0a-002e3701.pphosted.com (PPS) with ESMTPS id 3u342n1day-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 31 Oct 2023 16:51:40 +0000 X-Received: from p1lg14886.dc01.its.hpecorp.net (unknown [10.119.18.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14881.it.hpe.com (Postfix) with ESMTPS id A95BD805643; Tue, 31 Oct 2023 16:51:29 +0000 (UTC) X-Received: from cat.eag.rdlabs.hpecorp.net (unknown [16.231.227.36]) by p1lg14886.dc01.its.hpecorp.net (Postfix) with ESMTP id C133B80DEB0; Tue, 31 Oct 2023 16:51:16 +0000 (UTC) X-Received: by cat.eag.rdlabs.hpecorp.net (Postfix, from userid 178665) id 0F13B221EEC; Tue, 31 Oct 2023 11:51:16 -0500 (CDT) From: "Henz, Patrick" To: devel@edk2.groups.io Cc: hao.a.wu@intel.com, ray.ni@intel.com, Patrick Henz Subject: [edk2-devel] [PATCH] MdeModulePkg/XhciDxe: Non-zero start/stop values in XhcGetElapsedTicks Date: Tue, 31 Oct 2023 11:51:14 -0500 Message-Id: X-Proofpoint-GUID: PQ0B7XGbI1gfBr1_Lzr_jrQ8fr0WaJlV X-Proofpoint-ORIG-GUID: PQ0B7XGbI1gfBr1_Lzr_jrQ8fr0WaJlV X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 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,patrick.henz@hpe.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: Hn9p5waJ01phYTrialLcJqJ0x1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698771132807100003 Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D4578 The implementation of XhcGetElapsedTicks did not account for non-zero start and stop values for the performance counter timer, potentially resulting in an incorrect elapsed tick count getting returned to the caller. Account for non-zero start and stop values when calculating the elapsed tick count. Cc: Hao A Wu Cc: Ray Ni Signed-off-by: Patrick Henz Reviewed-by: Reviewed-by: Laszlo Ersek --- MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c b/MdeModulePkg/Bus/Pci/Xhc= iDxe/Xhci.c index 7a2e32a9dd..6cb97b7452 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c +++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c @@ -2389,7 +2389,7 @@ XhcGetElapsedTicks ( // Counter counts upwards, check for an overflow condition // if (*PreviousTick > CurrentTick) { - Delta =3D (mPerformanceCounterEndValue - *PreviousTick) + CurrentTic= k; + Delta =3D (CurrentTick - mPerformanceCounterStartValue) + (mPerforma= nceCounterEndValue - *PreviousTick); } else { Delta =3D CurrentTick - *PreviousTick; } @@ -2398,7 +2398,7 @@ XhcGetElapsedTicks ( // Counter counts downwards, check for an underflow condition // if (*PreviousTick < CurrentTick) { - Delta =3D (mPerformanceCounterStartValue - CurrentTick) + *PreviousT= ick; + Delta =3D (mPerformanceCounterStartValue - CurrentTick) + (*Previous= Tick - mPerformanceCounterEndValue); } else { Delta =3D *PreviousTick - CurrentTick; } --=20 2.34.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 (#110434): https://edk2.groups.io/g/devel/message/110434 Mute This Topic: https://groups.io/mt/102301510/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-