* [PATCH v5 02/17] rtc: rzn1: Handle EPROBE_DEFER for optional pps interrupt
[not found] <20260821135608.275233-1-prabhakar.mahadev-lad.rj@bp.renesas.com>
@ 2026-08-21 13:55 ` Prabhakar
2026-08-21 13:55 ` [PATCH v5 03/17] rtc: rzn1: Fix weekday underflow when alarm crosses month boundary Prabhakar
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Prabhakar @ 2026-08-21 13:55 UTC (permalink / raw)
To: Alexandre Belloni, Miquel Raynal, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Geert Uytterhoeven,
Magnus Damm, Wolfram Sang
Cc: linux-rtc, linux-renesas-soc, devicetree, linux-kernel, Prabhakar,
Biju Das, Fabrizio Castro, Lad Prabhakar, stable
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Check for -EPROBE_DEFER from platform_get_irq_byname_optional() and handle
the deferred probe request properly.
Although the "pps" interrupt is optional, an error code of -EPROBE_DEFER
indicates that the interrupt subsystem is not yet ready. Intercept this
specific error condition, assign it to the return value, and jump to the
dis_runtime_pm label to avoid ignoring a valid probe deferral.
Fixes: eea7791e00f33 ("rtc: rzn1: implement one-second accuracy for alarms")
Cc: stable@vger.kernel.org
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
v4->v5:
- Added Tested-by tag from Wolfram.
v3->v4:
- Added Reviewed-by tag from Wolfram.
v2->v3:
- No changes
v1->v2:
- No changes
---
drivers/rtc/rtc-rzn1.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
index 305f10a8a85b..aa27ad7f5941 100644
--- a/drivers/rtc/rtc-rzn1.c
+++ b/drivers/rtc/rtc-rzn1.c
@@ -464,6 +464,10 @@ static int rzn1_rtc_probe(struct platform_device *pdev)
}
irq = platform_get_irq_byname_optional(pdev, "pps");
+ if (irq == -EPROBE_DEFER) {
+ ret = irq;
+ goto dis_runtime_pm;
+ }
if (irq >= 0)
ret = devm_request_irq(&pdev->dev, irq, rzn1_rtc_1s_irq, 0, "RZN1 RTC 1s", rtc);
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v5 03/17] rtc: rzn1: Fix weekday underflow when alarm crosses month boundary
[not found] <20260821135608.275233-1-prabhakar.mahadev-lad.rj@bp.renesas.com>
2026-08-21 13:55 ` [PATCH v5 02/17] rtc: rzn1: Handle EPROBE_DEFER for optional pps interrupt Prabhakar
@ 2026-08-21 13:55 ` Prabhakar
2026-08-21 13:55 ` [PATCH v5 04/17] rtc: rzn1: Handle unset alarm weekday in rzn1_rtc_read_alarm Prabhakar
2026-08-21 13:55 ` [PATCH v5 06/17] rtc: rzn1: Disable alarm interrupt before reprogramming alarm registers Prabhakar
3 siblings, 0 replies; 7+ messages in thread
From: Prabhakar @ 2026-08-21 13:55 UTC (permalink / raw)
To: Alexandre Belloni, Miquel Raynal, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Geert Uytterhoeven,
Magnus Damm, Wolfram Sang
Cc: linux-rtc, linux-renesas-soc, devicetree, linux-kernel, Prabhakar,
Biju Das, Fabrizio Castro, Lad Prabhakar, stable
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
rzn1_rtc_set_alarm() calculates the alarm weekday from the difference
between the alarm day and the current day of the month. When the alarm
crosses a month boundary, this difference can become negative. Since
days_ahead is unsigned, it underflows and results in an incorrect
weekday being programmed into RZN1_RTC_ALW.
The RTC core already provides a fully populated struct rtc_time for
the alarm, including the correct tm_wday. Use tm->tm_wday directly
instead of recalculating the weekday from the day-of-month.
This avoids the underflow and ensures alarms scheduled across a month
boundary use the correct weekday.
Fixes: b5ad1bf00d2c4 ("rtc: rzn1: Add alarm support")
Cc: stable@vger.kernel.org
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Suggested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
v4->v5:
- Added Tested-by tag from Wolfram.
v3->v4:
- Made use of tm->tm_wday directly instead of recalculating the weekday
from the day-of-month.
- Updated commit message.
v2->v3:
- New patch to fix weekday underflow when alarm crosses month boundary.
---
drivers/rtc/rtc-rzn1.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
index aa27ad7f5941..8c70dbf8c7ec 100644
--- a/drivers/rtc/rtc-rzn1.c
+++ b/drivers/rtc/rtc-rzn1.c
@@ -260,7 +260,6 @@ static int rzn1_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
struct rzn1_rtc *rtc = dev_get_drvdata(dev);
struct rtc_time *tm = &alrm->time, tm_now;
unsigned long alarm, farest;
- unsigned int days_ahead, wday;
int ret;
ret = rzn1_rtc_read_time(dev, &tm_now);
@@ -273,13 +272,9 @@ static int rzn1_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
if (time_after(alarm, farest))
return -ERANGE;
- /* Convert alarm day into week day */
- days_ahead = tm->tm_mday - tm_now.tm_mday;
- wday = (tm_now.tm_wday + days_ahead) % 7;
-
writel(bin2bcd(tm->tm_min), rtc->base + RZN1_RTC_ALM);
writel(bin2bcd(tm->tm_hour), rtc->base + RZN1_RTC_ALH);
- writel(BIT(wday), rtc->base + RZN1_RTC_ALW);
+ writel(BIT(tm->tm_wday), rtc->base + RZN1_RTC_ALW);
rtc->tm_alarm = alrm->time;
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v5 04/17] rtc: rzn1: Handle unset alarm weekday in rzn1_rtc_read_alarm
[not found] <20260821135608.275233-1-prabhakar.mahadev-lad.rj@bp.renesas.com>
2026-08-21 13:55 ` [PATCH v5 02/17] rtc: rzn1: Handle EPROBE_DEFER for optional pps interrupt Prabhakar
2026-08-21 13:55 ` [PATCH v5 03/17] rtc: rzn1: Fix weekday underflow when alarm crosses month boundary Prabhakar
@ 2026-08-21 13:55 ` Prabhakar
2026-08-21 15:08 ` Wolfram Sang
2026-08-21 13:55 ` [PATCH v5 06/17] rtc: rzn1: Disable alarm interrupt before reprogramming alarm registers Prabhakar
3 siblings, 1 reply; 7+ messages in thread
From: Prabhakar @ 2026-08-21 13:55 UTC (permalink / raw)
To: Alexandre Belloni, Miquel Raynal, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Geert Uytterhoeven,
Magnus Damm, Wolfram Sang
Cc: linux-rtc, linux-renesas-soc, devicetree, linux-kernel, Prabhakar,
Biju Das, Fabrizio Castro, Lad Prabhakar, stable
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
RZN1_RTC_ALW is a weekday bitmask where bit N represents weekday N.
When no alarm has been configured, the register has its power-on-reset
value of zero.
rzn1_rtc_read_alarm() uses fls() to convert the weekday bitmask into a
weekday number. When RZN1_RTC_ALW is zero, fls(0) returns zero and
fls(wday) - 1 evaluates to -1. This invalid weekday is then used to
calculate the alarm date and can either leave tm_wday set to -1 or
produce a fabricated alarm date.
Treat a zero RZN1_RTC_ALW value as an unset alarm weekday and return
without calculating the alarm date. Move reading RZN1_RTC_CTL1 before
this check so that alrm->enabled is updated for both configured and
unconfigured alarms.
On a cold-booted board with no alarm configured, the following was
observed before the fix:
root@rzn2h-evk:~# cat /proc/driver/rtc
rtc_time : 00:00:19
rtc_date : 2000-01-01
alrm_time : 00:00:00
alrm_date : 2000-01-07
alarm_IRQ : no
alrm_pending : no
update IRQ enabled : no
periodic IRQ enabled : no
periodic IRQ frequency : 1
max user IRQ frequency : 64
24hr : yes
After the fix:
root@rzn2h-evk:~# cat /proc/driver/rtc
rtc_time : 00:00:25
rtc_date : 2000-01-01
alrm_time : 00:00:00
alrm_date : 2000-01-01
alarm_IRQ : no
alrm_pending : no
update IRQ enabled : no
periodic IRQ enabled : no
periodic IRQ frequency : 1
max user IRQ frequency : 64
24hr : yes
Fixes: b5ad1bf00d2c4 ("rtc: rzn1: Add alarm support")
Cc: stable@vger.kernel.org
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
v4->v5:
- New patch
---
drivers/rtc/rtc-rzn1.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
index 8c70dbf8c7ec..e0fdb591ba91 100644
--- a/drivers/rtc/rtc-rzn1.c
+++ b/drivers/rtc/rtc-rzn1.c
@@ -234,13 +234,24 @@ static int rzn1_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
if (ret)
return ret;
+ ctl1 = readl(rtc->base + RZN1_RTC_CTL1);
+ alrm->enabled = !!(ctl1 & (RZN1_RTC_CTL1_ALME | RZN1_RTC_CTL1_1SE));
+
min = readl(rtc->base + RZN1_RTC_ALM);
hour = readl(rtc->base + RZN1_RTC_ALH);
- wday = readl(rtc->base + RZN1_RTC_ALW);
tm->tm_sec = 0;
tm->tm_min = bcd2bin(min);
tm->tm_hour = bcd2bin(hour);
+
+ /*
+ * If wday is zero, no bit is set in RZN1_RTC_ALW. This is the
+ * register's power-on reset value.
+ */
+ wday = readl(rtc->base + RZN1_RTC_ALW);
+ if (!wday)
+ return 0;
+
delta_days = ((fls(wday) - 1) - tm->tm_wday + 7) % 7;
tm->tm_wday = fls(wday) - 1;
@@ -249,9 +260,6 @@ static int rzn1_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
rtc_time64_to_tm(alarm, tm);
}
- ctl1 = readl(rtc->base + RZN1_RTC_CTL1);
- alrm->enabled = !!(ctl1 & (RZN1_RTC_CTL1_ALME | RZN1_RTC_CTL1_1SE));
-
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v5 04/17] rtc: rzn1: Handle unset alarm weekday in rzn1_rtc_read_alarm
2026-08-21 13:55 ` [PATCH v5 04/17] rtc: rzn1: Handle unset alarm weekday in rzn1_rtc_read_alarm Prabhakar
@ 2026-08-21 15:08 ` Wolfram Sang
2026-08-21 20:43 ` Lad, Prabhakar
0 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2026-08-21 15:08 UTC (permalink / raw)
To: Prabhakar
Cc: Alexandre Belloni, Miquel Raynal, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Geert Uytterhoeven,
Magnus Damm, linux-rtc, linux-renesas-soc, devicetree,
linux-kernel, Prabhakar, Biju Das, Fabrizio Castro, Lad Prabhakar,
stable
[-- Attachment #1: Type: text/plain, Size: 2225 bytes --]
On Fri, Aug 21, 2026 at 02:55:55PM +0100, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> RZN1_RTC_ALW is a weekday bitmask where bit N represents weekday N.
> When no alarm has been configured, the register has its power-on-reset
> value of zero.
>
> rzn1_rtc_read_alarm() uses fls() to convert the weekday bitmask into a
> weekday number. When RZN1_RTC_ALW is zero, fls(0) returns zero and
> fls(wday) - 1 evaluates to -1. This invalid weekday is then used to
> calculate the alarm date and can either leave tm_wday set to -1 or
> produce a fabricated alarm date.
>
> Treat a zero RZN1_RTC_ALW value as an unset alarm weekday and return
> without calculating the alarm date. Move reading RZN1_RTC_CTL1 before
> this check so that alrm->enabled is updated for both configured and
> unconfigured alarms.
>
> On a cold-booted board with no alarm configured, the following was
> observed before the fix:
>
> root@rzn2h-evk:~# cat /proc/driver/rtc
> rtc_time : 00:00:19
> rtc_date : 2000-01-01
> alrm_time : 00:00:00
> alrm_date : 2000-01-07
> alarm_IRQ : no
> alrm_pending : no
> update IRQ enabled : no
> periodic IRQ enabled : no
> periodic IRQ frequency : 1
> max user IRQ frequency : 64
> 24hr : yes
>
> After the fix:
>
> root@rzn2h-evk:~# cat /proc/driver/rtc
> rtc_time : 00:00:25
> rtc_date : 2000-01-01
> alrm_time : 00:00:00
> alrm_date : 2000-01-01
> alarm_IRQ : no
> alrm_pending : no
> update IRQ enabled : no
> periodic IRQ enabled : no
> periodic IRQ frequency : 1
> max user IRQ frequency : 64
> 24hr : yes
The output of the tests could be dropped IMO, but I'll leave this for
the RTC maintainers.
> Fixes: b5ad1bf00d2c4 ("rtc: rzn1: Add alarm support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Other than that:
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v5 04/17] rtc: rzn1: Handle unset alarm weekday in rzn1_rtc_read_alarm
2026-08-21 15:08 ` Wolfram Sang
@ 2026-08-21 20:43 ` Lad, Prabhakar
0 siblings, 0 replies; 7+ messages in thread
From: Lad, Prabhakar @ 2026-08-21 20:43 UTC (permalink / raw)
To: Wolfram Sang
Cc: Alexandre Belloni, Miquel Raynal, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Geert Uytterhoeven,
Magnus Damm, linux-rtc, linux-renesas-soc, devicetree,
linux-kernel, Prabhakar, Biju Das, Fabrizio Castro, Lad Prabhakar,
stable
Hi Wolfram,
THank you for the review.
On Fri, Aug 21, 2026 at 4:08 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
>
> On Fri, Aug 21, 2026 at 02:55:55PM +0100, Prabhakar wrote:
> > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >
> > RZN1_RTC_ALW is a weekday bitmask where bit N represents weekday N.
> > When no alarm has been configured, the register has its power-on-reset
> > value of zero.
> >
> > rzn1_rtc_read_alarm() uses fls() to convert the weekday bitmask into a
> > weekday number. When RZN1_RTC_ALW is zero, fls(0) returns zero and
> > fls(wday) - 1 evaluates to -1. This invalid weekday is then used to
> > calculate the alarm date and can either leave tm_wday set to -1 or
> > produce a fabricated alarm date.
> >
> > Treat a zero RZN1_RTC_ALW value as an unset alarm weekday and return
> > without calculating the alarm date. Move reading RZN1_RTC_CTL1 before
> > this check so that alrm->enabled is updated for both configured and
> > unconfigured alarms.
> >
> > On a cold-booted board with no alarm configured, the following was
> > observed before the fix:
> >
> > root@rzn2h-evk:~# cat /proc/driver/rtc
> > rtc_time : 00:00:19
> > rtc_date : 2000-01-01
> > alrm_time : 00:00:00
> > alrm_date : 2000-01-07
> > alarm_IRQ : no
> > alrm_pending : no
> > update IRQ enabled : no
> > periodic IRQ enabled : no
> > periodic IRQ frequency : 1
> > max user IRQ frequency : 64
> > 24hr : yes
> >
> > After the fix:
> >
> > root@rzn2h-evk:~# cat /proc/driver/rtc
> > rtc_time : 00:00:25
> > rtc_date : 2000-01-01
> > alrm_time : 00:00:00
> > alrm_date : 2000-01-01
> > alarm_IRQ : no
> > alrm_pending : no
> > update IRQ enabled : no
> > periodic IRQ enabled : no
> > periodic IRQ frequency : 1
> > max user IRQ frequency : 64
> > 24hr : yes
>
> The output of the tests could be dropped IMO, but I'll leave this for
> the RTC maintainers.
>
I'll drop it.
Cheers,
Prabhakar
> > Fixes: b5ad1bf00d2c4 ("rtc: rzn1: Add alarm support")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Other than that:
>
> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v5 06/17] rtc: rzn1: Disable alarm interrupt before reprogramming alarm registers
[not found] <20260821135608.275233-1-prabhakar.mahadev-lad.rj@bp.renesas.com>
` (2 preceding siblings ...)
2026-08-21 13:55 ` [PATCH v5 04/17] rtc: rzn1: Handle unset alarm weekday in rzn1_rtc_read_alarm Prabhakar
@ 2026-08-21 13:55 ` Prabhakar
2026-08-21 15:11 ` Wolfram Sang
3 siblings, 1 reply; 7+ messages in thread
From: Prabhakar @ 2026-08-21 13:55 UTC (permalink / raw)
To: Alexandre Belloni, Miquel Raynal, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Geert Uytterhoeven,
Magnus Damm, Wolfram Sang
Cc: linux-rtc, linux-renesas-soc, devicetree, linux-kernel, Prabhakar,
Biju Das, Fabrizio Castro, Lad Prabhakar, stable
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
rzn1_rtc_set_alarm() updates RZN1_RTC_ALM, RZN1_RTC_ALH and
RZN1_RTC_ALW using separate MMIO writes without first disabling the
alarm interrupt. If a previous alarm is still enabled, the interrupt
can fire while the alarm registers contain a mixture of old and newly
written values.
Fix this by disabling the alarm interrupt before reprogramming ALM, ALH
and ALW with a call to rzn1_rtc_alarm_irq_enable().
Fixes: b5ad1bf00d2c4 ("rtc: rzn1: Add alarm support")
Cc: stable@vger.kernel.org
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
v4->v5:
- New patch
---
drivers/rtc/rtc-rzn1.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
index 44e8db466cb7..09631a3a5134 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);
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v5 06/17] rtc: rzn1: Disable alarm interrupt before reprogramming alarm registers
2026-08-21 13:55 ` [PATCH v5 06/17] rtc: rzn1: Disable alarm interrupt before reprogramming alarm registers Prabhakar
@ 2026-08-21 15:11 ` Wolfram Sang
0 siblings, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2026-08-21 15:11 UTC (permalink / raw)
To: Prabhakar
Cc: Alexandre Belloni, Miquel Raynal, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Geert Uytterhoeven,
Magnus Damm, linux-rtc, linux-renesas-soc, devicetree,
linux-kernel, Prabhakar, Biju Das, Fabrizio Castro, Lad Prabhakar,
stable
[-- Attachment #1: Type: text/plain, Size: 852 bytes --]
On Fri, Aug 21, 2026 at 02:55:57PM +0100, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> rzn1_rtc_set_alarm() updates RZN1_RTC_ALM, RZN1_RTC_ALH and
> RZN1_RTC_ALW using separate MMIO writes without first disabling the
> alarm interrupt. If a previous alarm is still enabled, the interrupt
> can fire while the alarm registers contain a mixture of old and newly
> written values.
>
> Fix this by disabling the alarm interrupt before reprogramming ALM, ALH
> and ALW with a call to rzn1_rtc_alarm_irq_enable().
>
> Fixes: b5ad1bf00d2c4 ("rtc: rzn1: Add alarm support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread