From nobody Mon Feb 9 15:10:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+75482+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+75482+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1621834186; cv=none; d=zohomail.com; s=zohoarc; b=PMHupHdt1G0NMZTtPdB1B9T/Wyr36wNg6U+x358KA4pS8N3YPJmRX0OknmC/7jbY7NOFoymMpe6PKptFiXRORBtblqwNYiSR452AwOm5c+36E8T0mHQnqNT57+A4R3HDmgrBLjJgkEEB30m+zUF38o++Em5PxOjiaqnKZ4Ly564= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621834186; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=I7C0L0zmR35vf9clYCXUQQ9Usl85nuaViHwNOmE8QgI=; b=ZGLDpjEBAUWzWlNNxMV9bbRIaR8i4k+j+kaUjCfHKMwD+I37qOblxApw85QOap+WqhchNMmTuMPf+xwRPkzhdMXfVQuXVPbVCifE91WQnp/s5a8lMLoZlmRkiZsUjQtt6CyP1hgHtvEltJhDLgI9h1qcTwfhh5E27X94ksCs40E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+75482+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1621834186753273.7286951754654; Sun, 23 May 2021 22:29:46 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ZYZdYY1788612x0whfIoR3cb; Sun, 23 May 2021 22:29:46 -0700 X-Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) by mx.groups.io with SMTP id smtpd.web08.19185.1621834180641212617 for ; Sun, 23 May 2021 22:29:41 -0700 X-Received: by mail-lj1-f179.google.com with SMTP id c15so31915027ljr.7 for ; Sun, 23 May 2021 22:29:40 -0700 (PDT) X-Gm-Message-State: LEBz3l5g3KJF4qEkjolbfj8hx1787277AA= X-Google-Smtp-Source: ABdhPJxQipLBEQTwDd9GXG6bNWmeJ5UHg/qvfH0mmCpUAEdYGQ2GH2Do4GabeccHmc7Eel0AGzS0ug== X-Received: by 2002:a05:651c:1063:: with SMTP id y3mr15410659ljm.183.1621834178965; Sun, 23 May 2021 22:29:38 -0700 (PDT) X-Received: from gilgamesh.semihalf.com (host-193.106.246.138.static.3s.pl. [193.106.246.138]) by smtp.gmail.com with ESMTPSA id w17sm90739lfp.300.2021.05.23.22.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 May 2021 22:29:38 -0700 (PDT) From: "Marcin Wojtas" To: devel@edk2.groups.io Cc: leif@nuviainc.com, ardb+tianocore@kernel.org, Samer.El-Haj-Mahmoud@arm.com, sunny.Wang@arm.com, gjb@semihalf.com, upstream@semihalf.com, Marcin Wojtas Subject: [edk2-devel] [edk2-platforms PATCH 6/6] Marvell: RealTimeClockLib: Rework LibGetWakeupTime/LibSetWakeupTime Date: Mon, 24 May 2021 07:29:19 +0200 Message-Id: <20210524052919.2496579-7-mw@semihalf.com> In-Reply-To: <20210524052919.2496579-1-mw@semihalf.com> References: <20210524052919.2496579-1-mw@semihalf.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,mw@semihalf.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1621834186; bh=OE7RYT5nt6DJBgSd4M7dPsZLPbqj8eAbV9o8zqadRHk=; h=Cc:Date:From:Reply-To:Subject:To; b=E2lK0dsho4mzp3KhmsHLthAsI9dd+PuOIPGZbRezNeyLSokcUwiMmG23uxwQtqTgY3K wQDwxp7AqKs78A7r+4iLXKr61xUe7hSZTadGnQYQqXXAPH0VPUIsVkXDnV7MzPxV/qulQ tyyImjCv2MMqc/SHRvnwldEVA9ht1RZ+nLQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Apply multiple fixes to the Marvell RealTimeClockLib wakeup library callbacks. LibGetWakeupTime: * Add input parameters validation * Fix 'Pending' value check LibSetWakeupTime: * Allow disabling the wakeup timer regardless the input 'Time' value * Use more generic 'Time' value verification, which is more strict than the replaced custom one. * Use proper alarm mask for 'Pending' signalling With above the ACS3.0 FWTS and SCT timer tests pass cleanly. Signed-off-by: Marcin Wojtas Reviewed-by: Ard Biesheuvel --- Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.h | = 2 +- Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c | 2= 9 ++++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeCl= ockLib.h b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeCloc= kLib.h index 7fa1d092e4..c33e63d107 100644 --- a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.h +++ b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.h @@ -17,7 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define RTC_BRIDGE_TIMING_CTRL0_REG_OFFS 0x80 #define RTC_BRIDGE_TIMING_CTRL1_REG_OFFS 0x84 #define RTC_IRQ_STATUS_REG 0x90 -#define RTC_IRQ_ALARM_MASK 0x1 +#define RTC_IRQ_ALARM_MASK 0x2 #define RTC_WRITE_PERIOD_DELAY_MASK 0xFFFF #define RTC_WRITE_PERIOD_DELAY_DEFAULT 0x3FF #define RTC_WRITE_SETUP_DELAY_MASK (0xFFFF << 16) diff --git a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeCl= ockLib.c b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeCloc= kLib.c index a48d44ed83..49c9385d53 100644 --- a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c +++ b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c @@ -140,11 +140,15 @@ LibGetWakeupTime ( { UINT32 WakeupSeconds; =20 + if (Time =3D=3D NULL || Enabled =3D=3D NULL || Pending =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + *Enabled =3D MmioRead32 (mArmadaRtcBase + RTC_IRQ_2_CONFIG_REG) & RTC_IR= Q_ALARM_EN; =20 *Pending =3D MmioRead32 (mArmadaRtcBase + RTC_IRQ_STATUS_REG) & RTC_IRQ_= ALARM_MASK; // Ack pending alarm - if (Pending) { + if (*Pending) { MmioWrite32 (mArmadaRtcBase + RTC_IRQ_STATUS_REG, RTC_IRQ_ALARM_MASK); } =20 @@ -176,14 +180,14 @@ LibSetWakeupTime ( { UINTN WakeupSeconds; =20 - // - // Because the Armada RTC uses a 32-bit counter for seconds, - // the maximum time span is just over 136 years. - // Time is stored in Unix Epoch format, so it starts in 1970, - // Therefore it can not exceed the year 2106. - // - if ((Time->Year < 1970) || (Time->Year >=3D 2106)) { - return EFI_UNSUPPORTED; + // Handle timer disabling case + if (!Enabled) { + RtcDelayedWrite (RTC_IRQ_2_CONFIG_REG, 0); + return EFI_SUCCESS; + } + + if (Time =3D=3D NULL || !IsTimeValid (Time)) { + return EFI_INVALID_PARAMETER; } =20 // Convert time to raw seconds @@ -195,11 +199,8 @@ LibSetWakeupTime ( // Issue delayed write to alarm register RtcDelayedWrite (RTC_ALARM_2_REG, (UINT32)WakeupSeconds); =20 - if (Enabled) { - MmioWrite32 (mArmadaRtcBase + RTC_IRQ_2_CONFIG_REG, RTC_IRQ_ALARM_EN); - } else { - MmioWrite32 (mArmadaRtcBase + RTC_IRQ_2_CONFIG_REG, 0); - } + // Enable wakeup timer + RtcDelayedWrite (RTC_IRQ_2_CONFIG_REG, RTC_IRQ_ALARM_EN); =20 return EFI_SUCCESS; } --=20 2.29.0 -=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 (#75482): https://edk2.groups.io/g/devel/message/75482 Mute This Topic: https://groups.io/mt/83044532/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-