From nobody Thu Oct 31 23:59:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 152483753699130.657973858199853; Fri, 27 Apr 2018 06:58:56 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7D914203B8CA5; Fri, 27 Apr 2018 06:58:55 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 94DEE203B8CA1 for ; Fri, 27 Apr 2018 06:58:53 -0700 (PDT) Received: from E107992.Emea.Arm.com (e107992.emea.arm.com [10.10.1.106]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w3RDwoLI003838; Fri, 27 Apr 2018 14:58:50 +0100 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=alexei.fedorov@arm.com; receiver=edk2-devel@lists.01.org From: AlexeiFedorov To: edk2-devel@lists.01.org Date: Fri, 27 Apr 2018 14:58:43 +0100 Message-Id: <1524837524-48208-1-git-send-email-alexei.fedorov@arm.com> X-Mailer: git-send-email 2.7.1.windows.1 Subject: [edk2] [PATCH v1] ArmPkg: Fix bug in Generic Waitchdog driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com, ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, Stephanie.Hughes-Fitt@arm.com MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In ArmPkg\Drivers\GenericWatchdogDxe\GenericWatchdogDxe.c the following functions WatchdogWriteOffsetRegister(); WatchdogWriteCompareRegister(); WatchdogEnable(); WatchdogDisable(); provide write access to ARM Generic Watchdog registers and use the values returned by MmioWrite32() and MmioWrite64() as EFI_STATUS return codes. Because MmioWriteXY() return the value passed as its write parameter, Generic Watchdog access functions can return error code which is different from EFI_SUCCESS, e.g. the following call Status =3D WatchdogWriteOffsetRegister (MAX_UINT32); if (EFI_ERROR (Status)) { return Status; } will return MAX_UINT32 defined in MdePkg\Include\Base.h as #define MAX_UINT32 ((UINT32)0xFFFFFFFF) This commit declares all the functions listed above as VOID and removes the code for checking their return values. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Alexei Fedorov Reviewed-by: Evan Lloyd Reviewed-by: Ard Biesheuvel --- All the changes can be seen at https://github.com/AlexeiFedorov/edk2/tree/84_generic_timer_v1 Notes: v1: - Fix functions writing to ARM Generic Watchdog's registers [Alexei] ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c | 37 +++++++++-----= ------ 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c b/ArmPk= g/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c index 252ba5bf321e379ef440830cab468af7c55905b3..3180f011253639c408b7151c79c= 2106a352c7340 100644 --- a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c +++ b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c @@ -1,6 +1,6 @@ /** @file * -* Copyright (c) 2013-2017, ARM Limited. All rights reserved. +* Copyright (c) 2013-2018, ARM Limited. All rights reserved. * * This program and the accompanying materials * are licensed and made available under the terms and conditions of the B= SD @@ -43,36 +43,36 @@ UINT64 mNumTimerTicks =3D 0; =20 EFI_HARDWARE_INTERRUPT2_PROTOCOL *mInterruptProtocol; =20 -EFI_STATUS +VOID WatchdogWriteOffsetRegister ( UINT32 Value ) { - return MmioWrite32 (GENERIC_WDOG_OFFSET_REG, Value); + MmioWrite32 (GENERIC_WDOG_OFFSET_REG, Value); } =20 -EFI_STATUS +VOID WatchdogWriteCompareRegister ( UINT64 Value ) { - return MmioWrite64 (GENERIC_WDOG_COMPARE_VALUE_REG, Value); + MmioWrite64 (GENERIC_WDOG_COMPARE_VALUE_REG, Value); } =20 -EFI_STATUS +VOID WatchdogEnable ( VOID ) { - return MmioWrite32 (GENERIC_WDOG_CONTROL_STATUS_REG, GENERIC_WDOG_ENABLE= D); + MmioWrite32 (GENERIC_WDOG_CONTROL_STATUS_REG, GENERIC_WDOG_ENABLED); } =20 -EFI_STATUS +VOID WatchdogDisable ( VOID ) { - return MmioWrite32 (GENERIC_WDOG_CONTROL_STATUS_REG, GENERIC_WDOG_DISABL= ED); + MmioWrite32 (GENERIC_WDOG_CONTROL_STATUS_REG, GENERIC_WDOG_DISABLED); } =20 /** On exiting boot services we must make sure the Watchdog Timer @@ -163,9 +163,7 @@ WatchdogRegisterHandler ( then the watchdog timer is disabled. =20 @retval EFI_SUCCESS The watchdog timer has been programmed to = fire - in Time 100ns units. - @retval EFI_DEVICE_ERROR A watchdog timer could not be programmed d= ue - to a device error. + in TimerPeriod 100ns units. =20 **/ EFI_STATUS @@ -176,12 +174,12 @@ WatchdogSetTimerPeriod ( ) { UINTN SystemCount; - EFI_STATUS Status; =20 // if TimerPeriod is 0, this is a request to stop the watchdog. if (TimerPeriod =3D=3D 0) { mNumTimerTicks =3D 0; - return WatchdogDisable (); + WatchdogDisable (); + return EFI_SUCCESS; } =20 // Work out how many timer ticks will equate to TimerPeriod @@ -195,19 +193,16 @@ WatchdogSetTimerPeriod ( because enabling the watchdog causes an "explicit refresh", which clobbers the compare register (WCV). In order to make sure this doe= sn't trigger an interrupt, set the offset to max. */ - Status =3D WatchdogWriteOffsetRegister (MAX_UINT32); - if (EFI_ERROR (Status)) { - return Status; - } + WatchdogWriteOffsetRegister (MAX_UINT32); WatchdogEnable (); SystemCount =3D ArmGenericTimerGetSystemCount (); - Status =3D WatchdogWriteCompareRegister (SystemCount + mNumTimerT= icks); + WatchdogWriteCompareRegister (SystemCount + mNumTimerTicks); } else { - Status =3D WatchdogWriteOffsetRegister ((UINT32)mNumTimerTicks); + WatchdogWriteOffsetRegister ((UINT32)mNumTimerTicks); WatchdogEnable (); } =20 - return Status; + return EFI_SUCCESS; } =20 /** --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel