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 DE6DD941CD3 for ; Fri, 19 Jan 2024 15:46:22 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=peXSgp4C7EzgPqwFsH1euGMP0eZ4xrDjrP/cd/cmANA=; 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=1705679181; v=1; b=Q35BnLhPq9QYKoCs6FOxan2m0rC22TGjbQ1Bu2QPFHt/1+xTngEDNvaf7Vr7W+Lv9XRvqBCN ekbWuPOC8QKMy+K3TEdmERlj9PromnZ2boZTCVEBBfxUCEX4tEySB4KA+PWwW5rFgROltDdHaBG BUcMqSD4rPUQVJIv/h35KAHs= X-Received: by 127.0.0.2 with SMTP id gnjVYY7687511xfucnVd4dES; Fri, 19 Jan 2024 07:46:21 -0800 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.106]) by mx.groups.io with SMTP id smtpd.web10.25619.1705679180683156874 for ; Fri, 19 Jan 2024 07:46:20 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mD1+FHf0oEMTJCmCYK/Qqpoek2jTEShVwn3xYJxnT+12lISm0xHyxGnqN/zri6PqmpGARI5k9mdVj5kDxjZButztX079zMmlSm+Nzk4yjisLWeVDv3xBP5M5xjUeAfuGIUGewXW4t2axZIij2FS0V1/xF/utuOiBPB1y+QNbbGENsC5eYw2nuQ8GDMv7NanD5LClsJoii3xBpHWKPkgbUEXIV1rxl3sH7Fiwh0gPd8UdIMuc9nHk24IJ98HlwVNHtARWeWoCgcLRdbYRBK64PMWo+Tu81W5ikQG1+nbhU/hQprjgx1KcHblYb+0KQix3etV8QtOXKR3RcdVxOdvHyg== 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=OxRSgQOC9JKh0y9XCK7ZYY4bsRT6B5AbL/orDGfnuoE=; b=jUFuNzYpHOOknTCDar2ubzb2U2r2mWUYYDdsXQqRXhDau0WFHbnY31e3N1k1pbekXbxX8qEYI0TOexjOK7aVPpqrGYqDk/hzAezypx3M6R0kjdz/vaxOf4OIDV8aCUWB4AfwoK7gHztVTsH8i8pSEgJ0nWaZ1UGPz/JOG1unQions0GA7INSIItrEmu3dCM3y69shm/s/2mQvgx6GzlOFIiRXfTCF9bZ01AEKXqKURza/X21/JMlFjaBLb16VZJcno3fduGfg7UyKSjZU0H/ez52ivbcFOv1wufwub0P57CZ3c5D19H0TMX85GYhSva5gIp/nW3+eUpH5lf4KPuh/A== 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 MW4PR01MB6482.prod.exchangelabs.com (2603:10b6:303:65::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.26; Fri, 19 Jan 2024 15:46:17 +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.7202.024; Fri, 19 Jan 2024 15:46:17 +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 v4 2/3] ArmPkg: Introduce global mTimerPeriod and remove calculation Date: Fri, 19 Jan 2024 08:45:53 -0700 Message-ID: <20240119154554.1052736-3-rebecca@os.amperecomputing.com> In-Reply-To: <20240119154554.1052736-1-rebecca@os.amperecomputing.com> References: <20240119154554.1052736-1-rebecca@os.amperecomputing.com> X-ClientProxiedBy: CH2PR04CA0022.namprd04.prod.outlook.com (2603:10b6:610:52::32) To LV3PR01MB8464.prod.exchangelabs.com (2603:10b6:408:1a3::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV3PR01MB8464:EE_|MW4PR01MB6482:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a028bb6-3f20-4876-29e6-08dc1905c694 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: XcmqpLVwYZcDh7v4VdwQ1bRvL+9uqthBmOZ9UJ+2bAEc2efOgThGHEm3y9VnvtIYCwaenOqKci7eGewOg6lGPIV2TfmdzfTbTlNNfNxbRIx2kNjArRZGNy5O/pLyz8EcG1kFgn5XPDoQTvNf/s+MS/pFhLQmDPnBp1QuwD72IE8itwRHLEL09xJ9sxQBHP5Ft167PwTSIOiAIJfFvqxn/uV4q5xkgXT//VXJMAmGg7Esi1FBpm6aDaGQX06vZCbdXpF87aFp70yokizMCCknb5jWnzO0xE1yC8H4fqSFRgnYFG9gZ8PYf3YX1l7ub9twU9+NRTbyQHyL3STmuyFk24RHzFLE93IAOEqaV15BjbF8ySQocTiYJrWR9O/hEH+LqT6ZLZW6GBdR3g4ughLD1IY1pPP59osRY49ip34xssqZYwJLeE63xyyY/fvcwxdjPW9DKyYuLir8KHFsZvDdUvFks51DY+JPS5CIHX+yQj269Bjn2XGE8gE1/h5BRRfwr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fnYbzaEPctukUzWDOMhHJ0JMAwRwFS3?= =?us-ascii?Q?t0yuLaskY0H9su6qgAKcmaQ=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2a028bb6-3f20-4876-29e6-08dc1905c694 X-MS-Exchange-CrossTenant-AuthSource: LV3PR01MB8464.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2024 15:46:17.8134 (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: JobT5CEG9yNb3FyphzXmsJOC2KvgFMPtXTHx+HHk8PrLSlOic0f3Qv5OSw/wFc4YxOKwBZn27aA3ew3DSyK9QSzL99uO24eOtAt8Eta9P9hUpB9km06fgP/y+y7J2hSg X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR01MB6482 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: xdI7vmbP5x2Yt6yzNyI0HNJtx7686176AA= 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=Q35BnLhP; 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 | 35 +++++++++-----= ------ 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c b/ArmPk= g/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c index 20549aa91d94..8dd247c44e8f 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 STATIC UINT8 WatchdogRevision; =20 @@ -95,7 +92,7 @@ WatchdogExitBootServicesEvent ( ) { WatchdogDisable (); - mNumTimerTicks =3D 0; + mTimerPeriod =3D 0; } =20 /* This function is called when the watchdog's first signal (WS0) goes hig= h. @@ -110,7 +107,6 @@ WatchdogInterruptHandler ( ) { STATIC CONST CHAR16 ResetString[] =3D L"The generic watchdog timer ran = out."; - UINT64 TimerPeriod; =20 WatchdogDisable (); =20 @@ -123,8 +119,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 ( @@ -204,22 +199,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 @@ -227,9 +227,9 @@ WatchdogSetTimerPeriod ( WatchdogWriteOffsetRegister (MAX_UINT48); WatchdogEnable (); SystemCount =3D ArmGenericTimerGetSystemCount (); - WatchdogWriteCompareRegister (SystemCount + mNumTimerTicks); + WatchdogWriteCompareRegister (SystemCount + NumTimerTicks); } else { - WatchdogWriteOffsetRegister (mNumTimerTicks); + WatchdogWriteOffsetRegister (NumTimerTicks); WatchdogEnable (); } =20 @@ -264,7 +264,7 @@ WatchdogGetTimerPeriod ( return EFI_INVALID_PARAMETER; } =20 - *TimerPeriod =3D ((TIME_UNITS_PER_SECOND / mTimerFrequencyHz) * mNumTime= rTicks); + *TimerPeriod =3D mTimerPeriod; =20 return EFI_SUCCESS; } @@ -332,9 +332,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, @@ -376,9 +373,9 @@ GenericWatchdogEntry ( ); ASSERT_EFI_ERROR (Status); =20 - mNumTimerTicks =3D 0; WatchdogIId =3D MmioRead32 (GENERIC_WDOG_IID_REG); WatchdogRevision =3D (WatchdogIId >> GENERIC_WDOG_IID_REV_SHIFT) & GENER= IC_WDOG_IID_REV_MASK; + 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 (#114087): https://edk2.groups.io/g/devel/message/114087 Mute This Topic: https://groups.io/mt/103832318/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-