From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.107.6.48; helo=eur04-db3-obe.outbound.protection.outlook.com; envelope-from=udit.kumar@nxp.com; receiver=edk2-devel@lists.01.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60048.outbound.protection.outlook.com [40.107.6.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7E86F2119AC38 for ; Tue, 18 Dec 2018 08:00:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rsWZ0reXqDnkCTzMQPsvrATs7OqhCoVEz3JodvjyIRU=; b=cNRh+DJr+DuFF+KIKGXeKkMJwQsGdZ/V++736+HckbALrGOHg4RBpO05xw/AAwMJhxXR01PXCgolg+DxGSAXJKXyNydlNUAgH71Hmi0LHcug5tVYZZln5IKtJ4Zx+ec7/WmJ6YaJxql2JlHJ5dfRxukoXpi+tb0a9cVaVYTPvwA= Received: from VI1PR04MB4640.eurprd04.prod.outlook.com (20.177.56.27) by VI1PR04MB3150.eurprd04.prod.outlook.com (10.170.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.19; Tue, 18 Dec 2018 16:00:37 +0000 Received: from VI1PR04MB4640.eurprd04.prod.outlook.com ([fe80::1dd2:4456:83ee:1bd5]) by VI1PR04MB4640.eurprd04.prod.outlook.com ([fe80::1dd2:4456:83ee:1bd5%2]) with mapi id 15.20.1425.023; Tue, 18 Dec 2018 16:00:37 +0000 From: Udit Kumar To: Ard Biesheuvel , "edk2-devel@lists.01.org" Thread-Topic: [PATCH 4/4] ArmPkg/GenericWatchdogDxe: implement RegisterHandler() method Thread-Index: AQHUltMJmJPb2f/FWU2tNbMlxP19qqWEp9pQ Date: Tue, 18 Dec 2018 16:00:37 +0000 Message-ID: References: <20181218131015.20062-1-ard.biesheuvel@linaro.org> <20181218131015.20062-5-ard.biesheuvel@linaro.org> In-Reply-To: <20181218131015.20062-5-ard.biesheuvel@linaro.org> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=udit.kumar@nxp.com; x-originating-ip: [182.69.235.121] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR04MB3150; 6:6qN42ZHXk2URmqR+RwLrqaUMU/x2Z6GNJYncsqH6Hl8OPNgpEaAB/vxen6eDtQZ41ggKBzXvPNzhUnVfewN6IoKBOf2rdrzP94xD5OW7MkT4PjGn+VkAvOCBNGSAOu9gZaTLm8KwPIsewix8TJubgOVLJQEE6KN5HdLDfZuj1Y1zvFq2JXS+wSJnPFbGpk28mWXrUX5Dy8stgab7DB4e7n94Y3fJMnzFVga4/mBwMEmow3YTk2NchFIolZ6cX+nR+gCcRct2PW6h+TUnwn061tCN2FrRNzScqq9oEcqRVYecA7ShozaZ/M7L2rKaZ06AxeyxoutO8RVAZA8v2pckUhL4wp/9iFefiRtC9oh/oxzzsZSaSlawiQn/M7M/IWkqDbqMRTXkSoBGqRIdsdGc5yNzlEVV+ilVQ75TYJFg++FEWmR/hS7j0uRijTIsmAwSj/n2qSz4egbsbs4C1yhebQ==; 5:T86zNuz5p3p/piETbRT0qUJWsNkM3hV9a9gw0W6dlbHefs2bujO7UFwXAkQ27nTrXek1ZHTAGW+FvYJ6ckNw0SGUAPFa9IpC0KPvsDD1L/49yX/IgtONZ0QLUom6UiEO+OGu0hCvK1Tld8QFOowAY1QhPnIcusl8aLP1iJbMNeA=; 7:AxdIpzDUqVSXhgb4Q8KnSllmGu1JcIdzkffUc6yHc+qenmb8bKwyneiwDglcLQs93j/JMVEDGDfyPiijEuKU43Ji93ri0yoL+Yf/5ZqiBYsFgIIIqvQLurqTE1um188mH4BPOmj1BsZYkoc/MGuz7w== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: f21907c9-d48d-4cc7-8c2d-08d66501f3ce x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR04MB3150; x-ms-traffictypediagnostic: VI1PR04MB3150: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3231475)(944501520)(52105112)(3002001)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:VI1PR04MB3150; BCL:0; PCL:0; RULEID:; SRVR:VI1PR04MB3150; x-forefront-prvs: 08902E536D x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(39860400002)(376002)(366004)(136003)(346002)(199004)(13464003)(189003)(106356001)(102836004)(105586002)(26005)(5660300001)(7736002)(2501003)(6246003)(55016002)(9686003)(33656002)(53936002)(74316002)(229853002)(3846002)(305945005)(6116002)(316002)(66066001)(81156014)(8676002)(81166006)(4326008)(2906002)(97736004)(6436002)(110136005)(8936002)(76176011)(71200400001)(7696005)(68736007)(14454004)(53546011)(6506007)(71190400001)(99286004)(256004)(14444005)(11346002)(478600001)(186003)(25786009)(476003)(486006)(446003)(78486014)(54906003)(44832011)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB3150; H:VI1PR04MB4640.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 2MQyDzItF0NnYm/2zu1ibSfFBX07nSRR2ystkfVwH1/oNdaLu8NH+ob3RU2M1e+WGqvo6MwG3Xfr6IG8rjHnoME/5DyU2bfGVP/5tRK1KkX+mN18ZI19hg95XebkoWQzZyDN+TVzH4LYHlwKHPxI2lqDq6PL6gQYHJVaAFTde250x4UTGEviiMIt3lr50Q1ttPRde26PfGdMa1NCnFpxVjJabpS+YURoKSQavSKlGk1iIUDhoVnB68XJM138BN7n4bP/F1KmCn0KrYce9sGrmSNPP9IdCHA9M6t2xEUL0vtBUa2+NzA0wmwHf8on+plk spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f21907c9-d48d-4cc7-8c2d-08d66501f3ce X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Dec 2018 16:00:37.7725 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3150 Subject: Re: [PATCH 4/4] ArmPkg/GenericWatchdogDxe: implement RegisterHandler() method X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Dec 2018 16:00:42 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Ard Biesheuvel > Sent: Tuesday, December 18, 2018 6:40 PM > To: edk2-devel@lists.01.org > Cc: Ard Biesheuvel ; Leif Lindholm > ; Sami Mujawar ; Thomas > Panakamattam Abraham ; Meenakshi Aggarwal > ; Udit Kumar ; Matteo > Carlini ; Nariman Poushin > > Subject: [PATCH 4/4] ArmPkg/GenericWatchdogDxe: implement > RegisterHandler() method >=20 > Even though UEFI does not appear to use it, let's implement the complete = PI > watchdog protocol, including handler registration, which will be invoked = instead > of the ResetSystem() runtime service when the watchdog timer expires. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c | 34 > ++++++++++++++------ > 1 file changed, 25 insertions(+), 9 deletions(-) >=20 > diff --git a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c > b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c > index 717a180a64ec..21118a3c88d1 100644 > --- a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c > +++ b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c > @@ -42,6 +42,7 @@ STATIC UINTN mTimerFrequencyHz =3D 0; STATIC UINT64 > mNumTimerTicks =3D 0; >=20 > STATIC EFI_HARDWARE_INTERRUPT2_PROTOCOL *mInterruptProtocol; > +STATIC EFI_WATCHDOG_TIMER_NOTIFY mWatchdogNotify; >=20 > STATIC > VOID > @@ -107,17 +108,25 @@ WatchdogInterruptHandler ( > ) > { > STATIC CONST CHAR16 ResetString[]=3D L"The generic watchdog timer ran = out."; > + UINT64 TimerPeriod; >=20 > WatchdogDisable (); >=20 > mInterruptProtocol->EndOfInterrupt (mInterruptProtocol, Source); >=20 > - gRT->ResetSystem ( > - EfiResetCold, > - EFI_TIMEOUT, > - StrSize (ResetString), > - (VOID *) &ResetString > - ); > + // > + // The notify function should be called with the elapsed number of > + ticks // since the watchdog was armed, which should exceed the timer p= eriod. > + // We don't actually know the elapsed number of ticks, so let's > + return // the timer period plus 1. > + // > + if (mWatchdogNotify !=3D NULL) { > + TimerPeriod =3D ((TIME_UNITS_PER_SECOND / mTimerFrequencyHz) * > mNumTimerTicks); > + mWatchdogNotify (TimerPeriod + 1); > + } else { > + gRT->ResetSystem (EfiResetCold, EFI_TIMEOUT, StrSize (ResetString), > + (CHAR16 *)ResetString); > + } Here too, please handle reset in all cases=20 =20 > // If we got here then the reset didn't work > ASSERT (FALSE); > @@ -155,9 +164,16 @@ WatchdogRegisterHandler ( > IN EFI_WATCHDOG_TIMER_NOTIFY NotifyFunction > ) > { > - // ERROR: This function is not supported. > - // The watchdog will reset the board > - return EFI_UNSUPPORTED; > + if (mWatchdogNotify =3D=3D NULL && NotifyFunction =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + if (mWatchdogNotify !=3D NULL && NotifyFunction !=3D NULL) { > + return EFI_ALREADY_STARTED; > + } > + > + mWatchdogNotify =3D NotifyFunction; > + return EFI_SUCCESS; > } >=20 > /** > -- > 2.17.1