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 13DBEAC0A7F for ; Fri, 5 Jan 2024 04:37:15 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=PK+L9oI60Ry0RFF7KfQopzpDuV7hz1l6cbh9/lROQvw=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1704429434; v=1; b=FZHiVpxAsxSyojtuqZu6rQ/jbl+LlCl6lBMCQ/SYt+uMs2NZLcJ7ZUNUxnn+vt/9+4wNaT4s sLMnP7rzfFj/gi9ROko33aCdEqRa376JXqEPzCjOjiAYmVyNiPLrq6lxohdi0BlGUxs7icVw6Gi Vuai8Eybdx0yn7X2CeGRIWOc= X-Received: by 127.0.0.2 with SMTP id 7kKxYY7687511xelQf8APidB; Thu, 04 Jan 2024 20:37:14 -0800 X-Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.113]) by mx.groups.io with SMTP id smtpd.web10.17200.1704429430875622080 for ; Thu, 04 Jan 2024 20:37:12 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZWjIOCJedcszHnFkCiVrokpB+qlii5rj3qO82YR4Ua6LGtJlaqWSb4iF5bLzQ7oMucER2Pb0UH1QNFrm1g2AY6JINUiRnTXKyN1nGsOBQHVw8tgtuvBCrc+EZjFBey5VxAn15xIch8yqMMkN5qAvJHuc6BEPjqz3i9TtLhJt9d/YEhuvhl0QKe7tOPBAjuEFNYaOHlb5vtrO+7BmooaiRW2e52vAGhUIIX/mawdNYExIzNUrndIVAGR5I2sO6SM2igCU2pmLCh9txCnIEifTZWOyghU6msMWEIZHDkY8/NVBXszZMF15NPtfdO9Bm5+JHgSuvlwjOsrAlMqxMbVojA== 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=l7jjFBpZXJ39N3gzhsEcRaSFnp5bLxVPs6GfCN2YayQ=; b=NhsdvBa2B0zryHk3bdVLhyxUwybfEDVNOkomXAwSzp/CzUNj4MeU4oISXN7BekJvtH7ZsfU3lzh6VUAWLipVn2455+5d9BpOIlk+YYTbzw8xpRCCBf18X3ZjvhtlQnFTozCuACOLE7n1Yl0FwZyeusjSP1pIAvBEpQXMPsCy8Q3+xPgXG5+GP/ZkNllwGIkEjePakCPZ7rrOeILl0Jughp3Iz7p8dgNZCeVK2XvzjXt1junn3CysLZq3zNWh4vznIP6Skn+eCdGeVPEzkFj8dfwLw5BxEazcCICpVpOaXWHizNHD2C77/5254Z06J60WRT5DbeVEXckmxh0CEqdPzw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none X-Received: from LV3PR01MB8464.prod.exchangelabs.com (2603:10b6:408:1a3::7) by SA0PR01MB6220.prod.exchangelabs.com (2603:10b6:806:e2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.13; Fri, 5 Jan 2024 04:37:09 +0000 X-Received: from LV3PR01MB8464.prod.exchangelabs.com ([fe80::7748:d4a3:bcd9:14c1]) by LV3PR01MB8464.prod.exchangelabs.com ([fe80::7748:d4a3:bcd9:14c1%6]) with mapi id 15.20.7159.013; Fri, 5 Jan 2024 04:37:08 +0000 From: "Rebecca Cran via groups.io" To: Leif Lindholm , Ard Biesheuvel , Sami Mujawar CC: Rebecca Cran , devel@edk2.groups.io Subject: [edk2-devel] [PATCH v2 2/3] ArmPkg: Introduce global mTimerPeriod and remove calculation Date: Thu, 4 Jan 2024 21:35:07 -0700 Message-ID: <20240105043508.461417-3-rebecca@os.amperecomputing.com> In-Reply-To: <20240105043508.461417-1-rebecca@os.amperecomputing.com> References: <20240105043508.461417-1-rebecca@os.amperecomputing.com> X-ClientProxiedBy: CH0PR03CA0267.namprd03.prod.outlook.com (2603:10b6:610:e5::32) To LV3PR01MB8464.prod.exchangelabs.com (2603:10b6:408:1a3::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV3PR01MB8464:EE_|SA0PR01MB6220:EE_ X-MS-Office365-Filtering-Correlation-Id: d7474eb2-1afb-4ad9-35d9-08dc0da7fa27 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: pt+dI39w+cnjBqNFHX6HGJNSEWHXdhT7uhwpcPkIj9GlYXfPkpjLgtW/aaCicC6uDDxsUag1FuX3A7w8U3/XTalTjsCzIENODXAyqCqRmfAsSvBHh1SKFmZfgUe2KZHWz9z6PYBnCk0OeT5AHDzDUsq4HqGyL8NGbyzgG/dMwP1EzC1IHGl6M6EeBEMkZc1ZvpsQASZwJdpDGwfHPV4EFlB6xUnHfO7zrN1ZiwCFUJ00yGr9/6SOi4lDuBBLU2dCdkEj/cW58fx4TxXOHDzlQE5OF9nsQk6zQZe46+i6MOw2SaYk1y80qC9X0na0Ll+wGAdXScPXGwjtOSGrkNG2cLUTnUSDx2KitRANFsJ4LW1ILltxtdgVu2qHpeQPlJcfym69J6EmCP33WfjR8wvCNlBNgDn88vq0XmC2jHRG5HN+Io+KoyV2j3yPTqiT6vKx66W/+QJmnMl0Ey5ibBq3rq5hrWg+ShHCnI8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ascii?Q?B0i0jEHTIIkOlBa/z7L913uyNmcEZw+PrPcGOU96lr7QVlTOwXz67vyOFIwI?= =?us-ascii?Q?WDRxeU+4TNGDhmiR8h4lgdQ=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7474eb2-1afb-4ad9-35d9-08dc0da7fa27 X-MS-Exchange-CrossTenant-AuthSource: LV3PR01MB8464.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2024 04:37:08.8114 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mBnXovFLGLgc1VlV8GpGm0amxSR+/m2DpgxINNM1M6ng9sVDCR7eXv3WsTJSS20WCkAE94UOfobPlUmHILKHOd2RhEVSskcjpXay3GyUTJxVufbiMApYTf1at2/O7yqD X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR01MB6220 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,rebecca@os.amperecomputing.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: Wi03nK97xzUCP0YRbex7TE7hx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=FZHiVpxA; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=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 The calculation of the timer period was broken. Introduce a global mTimerPeriod so the calculation can be removed. Since mTimerFrequencyHz is only used in one place, remove the global and make it a local variable. Do the same with mNumTimerTicks. Signed-off-by: Rebecca Cran --- ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c | 36 ++++++++++++++= ---------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c b/ArmPk= g/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c index f8c39458a53a..f74d0d1ced2e 100644 --- a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c +++ b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c @@ -28,13 +28,10 @@ in a second */ #define TIME_UNITS_PER_SECOND 10000000 =20 -// Tick frequency of the generic timer basis of the generic watchdog. -STATIC UINTN mTimerFrequencyHz =3D 0; - /* In cases where the compare register was set manually, information about how long the watchdog was asked to wait cannot be retrieved from hardwa= re. It is therefore stored here. 0 means the timer is not running. */ -STATIC UINT64 mNumTimerTicks =3D 0; +STATIC UINT64 mTimerPeriod =3D 0; =20 #define MAX_UINT48 0xFFFFFFFFFFFFULL =20 @@ -91,7 +88,8 @@ WatchdogExitBootServicesEvent ( ) { WatchdogDisable (); - mNumTimerTicks =3D 0; + mNumTimerTicks =3D 0; + mExitedBootServices =3D TRUE; } =20 /* This function is called when the watchdog's first signal (WS0) goes hig= h. @@ -106,7 +104,6 @@ WatchdogInterruptHandler ( ) { STATIC CONST CHAR16 ResetString[] =3D L"The generic watchdog timer ran = out."; - UINT64 TimerPeriod; =20 WatchdogDisable (); =20 @@ -119,8 +116,7 @@ WatchdogInterruptHandler ( // the timer period plus 1. // if (mWatchdogNotify !=3D NULL) { - TimerPeriod =3D ((TIME_UNITS_PER_SECOND / mTimerFrequencyHz) * mNumTim= erTicks); - mWatchdogNotify (TimerPeriod + 1); + mWatchdogNotify (mTimerPeriod + 1); } =20 gRT->ResetSystem ( @@ -200,22 +196,27 @@ WatchdogSetTimerPeriod ( IN UINT64 TimerPeriod // In 100ns un= its ) { - UINTN SystemCount; + UINTN SystemCount; + UINT64 TimerFrequencyHz; + UINT64 NumTimerTicks; =20 // if TimerPeriod is 0, this is a request to stop the watchdog. if (TimerPeriod =3D=3D 0) { - mNumTimerTicks =3D 0; + mTimerPeriod =3D 0; WatchdogDisable (); return EFI_SUCCESS; } =20 // Work out how many timer ticks will equate to TimerPeriod - mNumTimerTicks =3D (mTimerFrequencyHz * TimerPeriod) / TIME_UNITS_PER_SE= COND; + TimerFrequencyHz =3D ArmGenericTimerGetTimerFreq (); + ASSERT (TimerFrequencyHz !=3D 0); + mTimerPeriod =3D TimerPeriod; + NumTimerTicks =3D (TimerFrequencyHz * TimerPeriod) / TIME_UNITS_PER_SECO= ND; =20 /* If the number of required ticks is greater than the max the watchdog'= s offset register (WOR) can hold, we need to manually compute and set the compare register (WCV) */ - if (mNumTimerTicks > MAX_UINT48) { + if (NumTimerTicks > MAX_UINT48) { /* We need to enable the watchdog *before* writing to the compare regi= ster, because enabling the watchdog causes an "explicit refresh", which clobbers the compare register (WCV). In order to make sure this doe= sn't @@ -223,9 +224,9 @@ WatchdogSetTimerPeriod ( WatchdogWriteOffsetRegister (MAX_UINT48); WatchdogEnable (); SystemCount =3D ArmGenericTimerGetSystemCount (); - WatchdogWriteCompareRegister (SystemCount + mNumTimerTicks); + WatchdogWriteCompareRegister (SystemCount + NumTimerTicks); } else { - WatchdogWriteOffsetRegister (mNumTimerTicks); + WatchdogWriteOffsetRegister (NumTimerTicks); WatchdogEnable (); } =20 @@ -260,7 +261,7 @@ WatchdogGetTimerPeriod ( return EFI_INVALID_PARAMETER; } =20 - *TimerPeriod =3D ((TIME_UNITS_PER_SECOND / mTimerFrequencyHz) * mNumTime= rTicks); + *TimerPeriod =3D mTimerPeriod; =20 return EFI_SUCCESS; } @@ -327,9 +328,6 @@ GenericWatchdogEntry ( This will avoid conflicts with the universal watchdog */ ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiWatchdogTimerArchProtocolG= uid); =20 - mTimerFrequencyHz =3D ArmGenericTimerGetTimerFreq (); - ASSERT (mTimerFrequencyHz !=3D 0); - // Install interrupt handler Status =3D mInterruptProtocol->RegisterInterruptSource ( mInterruptProtocol, @@ -371,7 +369,7 @@ GenericWatchdogEntry ( ); ASSERT_EFI_ERROR (Status); =20 - mNumTimerTicks =3D 0; + mTimerPeriod =3D 0; WatchdogDisable (); =20 return EFI_SUCCESS; --=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 (#113211): https://edk2.groups.io/g/devel/message/113211 Mute This Topic: https://groups.io/mt/103537819/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-