From: sashiko-bot@kernel.org
To: Prabhakar <prabhakar.csengg@gmail.com>
Cc: wsa+renesas@sang-engineering.com,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org,
linux-rtc@vger.kernel.org
Subject: Re: [PATCH v5 06/17] rtc: rzn1: Disable alarm interrupt before reprogramming alarm registers
Date: Fri, 21 Aug 2026 14:10:40 +0000 [thread overview]
Message-ID: <20260821141041.57A191F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260821135608.275233-7-prabhakar.mahadev-lad.rj@bp.renesas.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Concurrent lockless read and write of `rtc->tm_alarm` and a race with delayed IRQ handlers can cause a newly configured alarm to be silently disabled.
--
--- Patch [6]: [PATCH v5 06/17] rtc: rzn1: Disable alarm interrupt before reprogramming alarm registers ---
commit 6227942d78d91abfb1648a64bce64f0011716b61
Author: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
rtc: rzn1: Disable alarm interrupt before reprogramming alarm registers
This commit updates rzn1_rtc_set_alarm() to disable the alarm interrupt
before reprogramming the alarm registers. This prevents the interrupt from
firing while the alarm registers contain a mixture of old and newly written
values.
> diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
> index 44e8db466cb78..09631a3a51345 100644
> --- a/drivers/rtc/rtc-rzn1.c
> +++ b/drivers/rtc/rtc-rzn1.c
> @@ -280,6 +280,11 @@ static int rzn1_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
> if (alarm > farest)
> return -ERANGE;
>
> + /* Disable alarm interrupts before reprogramming the alarm. */
> + ret = rzn1_rtc_alarm_irq_enable(dev, 0);
> + if (ret)
> + return ret;
> +
> writel(bin2bcd(tm->tm_min), rtc->base + RZN1_RTC_ALM);
> writel(bin2bcd(tm->tm_hour), rtc->base + RZN1_RTC_ALH);
> writel(BIT(tm->tm_wday), rtc->base + RZN1_RTC_ALW);
[Severity: High]
This is a pre-existing issue, but does this fully protect against a race
with a delayed IRQ handler?
If a previous alarm fires and the IRQ handler rzn1_rtc_alarm_irq() is
delayed on CPU1, and concurrently CPU0 runs rzn1_rtc_set_alarm():
CPU0 completes rzn1_rtc_set_alarm(), updating the lockless rtc->tm_alarm
and re-enabling the alarm by setting ALME in CTL1.
CPU1 then resumes in rzn1_rtc_alarm_irq():
if (rtc->tm_alarm.tm_sec == 0)
...
else
set_irq_bits = RZN1_RTC_CTL1_1SE;
guard(spinlock)(&rtc->ctl1_access_lock);
ctl1 = readl(rtc->base + RZN1_RTC_CTL1);
ctl1 &= ~RZN1_RTC_CTL1_ALME;
ctl1 |= set_irq_bits;
writel(ctl1, rtc->base + RZN1_RTC_CTL1);
Could CPU1 read the newly updated rtc->tm_alarm locklessly, and then
unconditionally clear ALME in CTL1? This sequence appears to silently
disable the newly configured alarm, which could result in missed wakeups.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260821135608.275233-1-prabhakar.mahadev-lad.rj@bp.renesas.com?part=6
next prev parent reply other threads:[~2026-08-21 14:10 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 13:55 [PATCH v5 00/17] Add RTC support for Renesas RZ/T2H and RZ/N2H SoCs Prabhakar
2026-08-21 13:55 ` [PATCH v5 01/17] dt-bindings: rtc: renesas,rzn1-rtc: Add RZ/T2H and RZ/N2H support Prabhakar
2026-08-21 14:05 ` sashiko-bot
2026-08-21 15:03 ` Wolfram Sang
2026-08-21 13:55 ` [PATCH v5 02/17] rtc: rzn1: Handle EPROBE_DEFER for optional pps interrupt Prabhakar
2026-08-21 14:07 ` sashiko-bot
2026-08-21 13:55 ` [PATCH v5 03/17] rtc: rzn1: Fix weekday underflow when alarm crosses month boundary Prabhakar
2026-08-21 14:08 ` sashiko-bot
2026-08-21 13:55 ` [PATCH v5 04/17] rtc: rzn1: Handle unset alarm weekday in rzn1_rtc_read_alarm Prabhakar
2026-08-21 14:10 ` sashiko-bot
2026-08-21 15:08 ` Wolfram Sang
2026-08-21 15:08 ` Wolfram Sang
2026-08-21 13:55 ` [PATCH v5 05/17] rtc: rzn1: Fix alarm range check truncation on 32-bit systems Prabhakar
2026-08-21 14:06 ` sashiko-bot
2026-08-21 13:55 ` [PATCH v5 06/17] rtc: rzn1: Disable alarm interrupt before reprogramming alarm registers Prabhakar
2026-08-21 14:10 ` sashiko-bot [this message]
2026-08-21 15:10 ` Wolfram Sang
2026-08-21 15:11 ` Wolfram Sang
2026-08-21 13:55 ` [PATCH v5 07/17] rtc: rzn1: Fix malformed MODULE_AUTHOR string Prabhakar
2026-08-21 14:01 ` sashiko-bot
2026-08-21 13:55 ` [PATCH v5 08/17] rtc: Kconfig: Broaden RTC_DRV_RZN1 dependency to ARCH_RENESAS Prabhakar
2026-08-21 14:02 ` sashiko-bot
2026-08-21 13:56 ` [PATCH v5 09/17] rtc: rzn1: Use pm_runtime_put_sync() Prabhakar
2026-08-21 14:08 ` sashiko-bot
2026-08-21 15:14 ` Wolfram Sang
2026-08-21 13:56 ` [PATCH v5 10/17] rtc: rzn1: Replace remove callback with devm_add_action_or_reset() Prabhakar
2026-08-21 14:07 ` sashiko-bot
2026-08-21 15:15 ` Wolfram Sang
2026-08-21 13:56 ` [PATCH v5 11/17] rtc: rzn1: Dynamically calculate synchronization delay based on clock rate Prabhakar
2026-08-21 14:05 ` sashiko-bot
2026-08-21 13:56 ` [PATCH v5 12/17] rtc: rzn1: Use temporary variable for struct device Prabhakar
2026-08-21 14:05 ` sashiko-bot
2026-08-21 13:56 ` [PATCH v5 13/17] rtc: rzn1: Consistently use dev_err_probe() Prabhakar
2026-08-21 14:03 ` sashiko-bot
2026-08-21 13:56 ` [PATCH v5 14/17] rtc: rzn1: use FIELD_PREP/FIELD_GET and GENMASK for register access Prabhakar
2026-08-21 14:06 ` sashiko-bot
2026-08-21 13:56 ` [PATCH v5 15/17] rtc: rzn1: Add OF match data to gate SUBU " Prabhakar
2026-08-21 14:08 ` sashiko-bot
2026-08-21 15:16 ` Wolfram Sang
2026-08-21 16:40 ` Alexandre Belloni
2026-08-21 13:56 ` [PATCH v5 16/17] rtc: rzn1: Drop trailing comma from OF match table sentinel Prabhakar
2026-08-21 14:07 ` sashiko-bot
2026-08-21 15:18 ` Wolfram Sang
2026-08-21 13:56 ` [PATCH v5 17/17] rtc: rzn1: Add support for Renesas RZ/T2H and RZ/N2H SoCs Prabhakar
2026-08-21 14:09 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260821141041.57A191F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=prabhakar.csengg@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wsa+renesas@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox