From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c0b::241; helo=mail-it0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it0-x241.google.com (mail-it0-x241.google.com [IPv6:2607:f8b0:4001:c0b::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 13C482033D1C2 for ; Mon, 30 Apr 2018 03:19:25 -0700 (PDT) Received: by mail-it0-x241.google.com with SMTP id c5-v6so8384888itj.1 for ; Mon, 30 Apr 2018 03:19:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=0tzM5P6EP5w5RRvB8fArGXrqfxMP17ghpuzq1UtO5bQ=; b=ElGT9U1F7TmeQeMs7DyASR6bmldn+n6zw0B9Bmb0iNDLXFf2aagEtbH8agaGMG3pmg 5dHOYyK3EW+jhG8JUiXPn+GAQZM8vKo6p5fqbeM3nkcEfHFStEhiC44faDAV4wc0QhHI xKV1y3QKcOatDZAmSbJy3x6AjCLtx9fxHe/og= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0tzM5P6EP5w5RRvB8fArGXrqfxMP17ghpuzq1UtO5bQ=; b=tAE25iHjcgHhMjSJw35RqIldbKCTjnLxQVg9fNJXFkx17QUSNHrJ8n1wCfPvpelqCs /iGQEqc7/pkpzp4GY5SZ4ndmGv4l4IP5dk0GF6Yx3tkm81Gam2h1xX6qUZ5SbZKGRfqN 9adLcbftD1lD+xbjBytwZAFIVM+lVFzhCqvgw2YTE4qFp8bbRwVDn3EmI5w6Hbk6Hz4t +mQALwZoNEM6UmlJRYZAZKWrTXYu5Hon/zO9yx/w2XHg+XYTRIInlGFSlAQbM2zQWruh R62Xm7j0uObrqi4KLMZQozP5IHqnUn5WZbimICX1HSm6w9qTjCQFUAjxPIOYuuVWf89q 2kxQ== X-Gm-Message-State: ALQs6tDczO5RgiL/MLsm71N7v3G36kxDuVKBQOI2eAoHla1AH0Z/tz8o aEzKVhF5DMlmmMdaJQMWonQyiTRxn1eRh1dXaMWQpg== X-Google-Smtp-Source: AB8JxZqHuUMYbZvqbLroVuy9N5R50Mgsp0Zh0AEchs8JLhZLyBglLf+n3UNln1JURc//JXdAePxwU5WE8KthQzIO0jM= X-Received: by 2002:a24:b14d:: with SMTP id c13-v6mr11365073itj.106.1525083564700; Mon, 30 Apr 2018 03:19:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.187.134 with HTTP; Mon, 30 Apr 2018 03:19:23 -0700 (PDT) In-Reply-To: <1524837524-48208-1-git-send-email-alexei.fedorov@arm.com> References: <1524837524-48208-1-git-send-email-alexei.fedorov@arm.com> From: Ard Biesheuvel Date: Mon, 30 Apr 2018 12:19:23 +0200 Message-ID: To: AlexeiFedorov Cc: "edk2-devel@lists.01.org" , Leif Lindholm , Matteo Carlini , Stephanie Hughes-Fitt , nd , Evan Lloyd , Sami Mujawar Subject: Re: [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: , X-List-Received-Date: Mon, 30 Apr 2018 10:19:26 -0000 Content-Type: text/plain; charset="UTF-8" On 27 April 2018 at 15:58, AlexeiFedorov wrote: > 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 = 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 > --- > 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(-) > Nice catch Reviewed-by: Ard Biesheuvel Pushed as 8fe18cba7694 Thanks > diff --git a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c > index 252ba5bf321e379ef440830cab468af7c55905b3..3180f011253639c408b7151c79c2106a352c7340 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 BSD > @@ -43,36 +43,36 @@ UINT64 mNumTimerTicks = 0; > > EFI_HARDWARE_INTERRUPT2_PROTOCOL *mInterruptProtocol; > > -EFI_STATUS > +VOID > WatchdogWriteOffsetRegister ( > UINT32 Value > ) > { > - return MmioWrite32 (GENERIC_WDOG_OFFSET_REG, Value); > + MmioWrite32 (GENERIC_WDOG_OFFSET_REG, Value); > } > > -EFI_STATUS > +VOID > WatchdogWriteCompareRegister ( > UINT64 Value > ) > { > - return MmioWrite64 (GENERIC_WDOG_COMPARE_VALUE_REG, Value); > + MmioWrite64 (GENERIC_WDOG_COMPARE_VALUE_REG, Value); > } > > -EFI_STATUS > +VOID > WatchdogEnable ( > VOID > ) > { > - return MmioWrite32 (GENERIC_WDOG_CONTROL_STATUS_REG, GENERIC_WDOG_ENABLED); > + MmioWrite32 (GENERIC_WDOG_CONTROL_STATUS_REG, GENERIC_WDOG_ENABLED); > } > > -EFI_STATUS > +VOID > WatchdogDisable ( > VOID > ) > { > - return MmioWrite32 (GENERIC_WDOG_CONTROL_STATUS_REG, GENERIC_WDOG_DISABLED); > + MmioWrite32 (GENERIC_WDOG_CONTROL_STATUS_REG, GENERIC_WDOG_DISABLED); > } > > /** On exiting boot services we must make sure the Watchdog Timer > @@ -163,9 +163,7 @@ WatchdogRegisterHandler ( > then the watchdog timer is disabled. > > @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 due > - to a device error. > + in TimerPeriod 100ns units. > > **/ > EFI_STATUS > @@ -176,12 +174,12 @@ WatchdogSetTimerPeriod ( > ) > { > UINTN SystemCount; > - EFI_STATUS Status; > > // if TimerPeriod is 0, this is a request to stop the watchdog. > if (TimerPeriod == 0) { > mNumTimerTicks = 0; > - return WatchdogDisable (); > + WatchdogDisable (); > + return EFI_SUCCESS; > } > > // 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 doesn't > trigger an interrupt, set the offset to max. */ > - Status = WatchdogWriteOffsetRegister (MAX_UINT32); > - if (EFI_ERROR (Status)) { > - return Status; > - } > + WatchdogWriteOffsetRegister (MAX_UINT32); > WatchdogEnable (); > SystemCount = ArmGenericTimerGetSystemCount (); > - Status = WatchdogWriteCompareRegister (SystemCount + mNumTimerTicks); > + WatchdogWriteCompareRegister (SystemCount + mNumTimerTicks); > } else { > - Status = WatchdogWriteOffsetRegister ((UINT32)mNumTimerTicks); > + WatchdogWriteOffsetRegister ((UINT32)mNumTimerTicks); > WatchdogEnable (); > } > > - return Status; > + return EFI_SUCCESS; > } > > /** > -- > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' > >