* [PATCH V2] rtc: zynqmp: Restore alarm functionality after kexec transition
@ 2025-07-30 14:21 Harini T
2025-09-03 15:22 ` T, Harini
2025-10-05 21:23 ` Alexandre Belloni
0 siblings, 2 replies; 4+ messages in thread
From: Harini T @ 2025-07-30 14:21 UTC (permalink / raw)
To: alexandre.belloni, michal.simek
Cc: linux-rtc, linux-arm-kernel, linux-kernel, git, Harini T
During kexec reboots, RTC alarms that are fired during the kernel
transition experience delayed execution. The new kernel would eventually
honor these alarms, but the interrupt handlers would only execute after
the driver probe is completed rather than at the intended alarm time.
This is because pending alarm interrupt status from the previous kernel
is not properly cleared during driver initialization, causing timing
discrepancies in alarm delivery.
To ensure precise alarm timing across kexec transitions, enhance the
probe function to:
1. Clear any pending alarm interrupt status from previous boot.
2. Detect existing valid alarms and preserve their state.
3. Re-enable alarm interrupts for future alarms.
Signed-off-by: Harini T <harini.t@amd.com>
---
Changes in V2:
- Remove shutdown handler to prevent alarm interrupts from being
disabled during kexec transitions.
- Add alarm state detection and restoration in probe.
V1 link: https://lore.kernel.org/linux-rtc/20250724170517.974356-1-harini.t@amd.com/T/#u
---
drivers/rtc/rtc-zynqmp.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
index f39102b66eac..3baa2b481d9f 100644
--- a/drivers/rtc/rtc-zynqmp.c
+++ b/drivers/rtc/rtc-zynqmp.c
@@ -277,6 +277,10 @@ static irqreturn_t xlnx_rtc_interrupt(int irq, void *id)
static int xlnx_rtc_probe(struct platform_device *pdev)
{
struct xlnx_rtc_dev *xrtcdev;
+ bool is_alarm_set = false;
+ u32 pending_alrm_irq;
+ u32 current_time;
+ u32 alarm_time;
int ret;
xrtcdev = devm_kzalloc(&pdev->dev, sizeof(*xrtcdev), GFP_KERNEL);
@@ -296,6 +300,17 @@ static int xlnx_rtc_probe(struct platform_device *pdev)
if (IS_ERR(xrtcdev->reg_base))
return PTR_ERR(xrtcdev->reg_base);
+ /* Clear any pending alarm interrupts from previous kernel/boot */
+ pending_alrm_irq = readl(xrtcdev->reg_base + RTC_INT_STS) & RTC_INT_ALRM;
+ if (pending_alrm_irq)
+ writel(pending_alrm_irq, xrtcdev->reg_base + RTC_INT_STS);
+
+ /* Check if a valid alarm is already set from previous kernel/boot */
+ alarm_time = readl(xrtcdev->reg_base + RTC_ALRM);
+ current_time = readl(xrtcdev->reg_base + RTC_CUR_TM);
+ if (alarm_time > current_time && alarm_time != 0)
+ is_alarm_set = true;
+
xrtcdev->alarm_irq = platform_get_irq_byname(pdev, "alarm");
if (xrtcdev->alarm_irq < 0)
return xrtcdev->alarm_irq;
@@ -337,6 +352,10 @@ static int xlnx_rtc_probe(struct platform_device *pdev)
xlnx_init_rtc(xrtcdev);
+ /* Re-enable alarm interrupt if a valid alarm was found */
+ if (is_alarm_set)
+ writel(RTC_INT_ALRM, xrtcdev->reg_base + RTC_INT_EN);
+
device_init_wakeup(&pdev->dev, true);
return devm_rtc_register_device(xrtcdev->rtc);
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH V2] rtc: zynqmp: Restore alarm functionality after kexec transition
2025-07-30 14:21 [PATCH V2] rtc: zynqmp: Restore alarm functionality after kexec transition Harini T
@ 2025-09-03 15:22 ` T, Harini
2025-09-25 6:04 ` T, Harini
2025-10-05 21:23 ` Alexandre Belloni
1 sibling, 1 reply; 4+ messages in thread
From: T, Harini @ 2025-09-03 15:22 UTC (permalink / raw)
To: T, Harini, alexandre.belloni, Simek, Michal
Cc: linux-rtc, linux-arm-kernel, linux-kernel, git (AMD-Xilinx)
[Public]
Hi Alexandre,
> -----Original Message-----
> From: Harini T <harini.t@amd.com>
> Sent: Wednesday, July 30, 2025 7:51 PM
> To: alexandre.belloni@bootlin.com; Simek, Michal
> <michal.simek@amd.com>
> Cc: linux-rtc@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
> kernel@vger.kernel.org; git (AMD-Xilinx) <git@amd.com>; T, Harini
> <Harini.T@amd.com>
> Subject: [PATCH V2] rtc: zynqmp: Restore alarm functionality after kexec
> transition
>
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
>
>
> During kexec reboots, RTC alarms that are fired during the kernel transition
> experience delayed execution. The new kernel would eventually honor these
> alarms, but the interrupt handlers would only execute after the driver probe
> is completed rather than at the intended alarm time.
>
> This is because pending alarm interrupt status from the previous kernel is not
> properly cleared during driver initialization, causing timing discrepancies in
> alarm delivery.
>
> To ensure precise alarm timing across kexec transitions, enhance the probe
> function to:
> 1. Clear any pending alarm interrupt status from previous boot.
> 2. Detect existing valid alarms and preserve their state.
> 3. Re-enable alarm interrupts for future alarms.
>
> Signed-off-by: Harini T <harini.t@amd.com>
> ---
> Changes in V2:
> - Remove shutdown handler to prevent alarm interrupts from being
> disabled during kexec transitions.
> - Add alarm state detection and restoration in probe.
>
> V1 link: https://lore.kernel.org/linux-rtc/20250724170517.974356-1-
> harini.t@amd.com/T/#u
> ---
> drivers/rtc/rtc-zynqmp.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c index
> f39102b66eac..3baa2b481d9f 100644
> --- a/drivers/rtc/rtc-zynqmp.c
> +++ b/drivers/rtc/rtc-zynqmp.c
> @@ -277,6 +277,10 @@ static irqreturn_t xlnx_rtc_interrupt(int irq, void *id)
> static int xlnx_rtc_probe(struct platform_device *pdev) {
> struct xlnx_rtc_dev *xrtcdev;
> + bool is_alarm_set = false;
> + u32 pending_alrm_irq;
> + u32 current_time;
> + u32 alarm_time;
> int ret;
>
> xrtcdev = devm_kzalloc(&pdev->dev, sizeof(*xrtcdev), GFP_KERNEL); @@
> -296,6 +300,17 @@ static int xlnx_rtc_probe(struct platform_device *pdev)
> if (IS_ERR(xrtcdev->reg_base))
> return PTR_ERR(xrtcdev->reg_base);
>
> + /* Clear any pending alarm interrupts from previous kernel/boot */
> + pending_alrm_irq = readl(xrtcdev->reg_base + RTC_INT_STS) &
> RTC_INT_ALRM;
> + if (pending_alrm_irq)
> + writel(pending_alrm_irq, xrtcdev->reg_base +
> + RTC_INT_STS);
> +
> + /* Check if a valid alarm is already set from previous kernel/boot */
> + alarm_time = readl(xrtcdev->reg_base + RTC_ALRM);
> + current_time = readl(xrtcdev->reg_base + RTC_CUR_TM);
> + if (alarm_time > current_time && alarm_time != 0)
> + is_alarm_set = true;
> +
> xrtcdev->alarm_irq = platform_get_irq_byname(pdev, "alarm");
> if (xrtcdev->alarm_irq < 0)
> return xrtcdev->alarm_irq; @@ -337,6 +352,10 @@ static int
> xlnx_rtc_probe(struct platform_device *pdev)
>
> xlnx_init_rtc(xrtcdev);
>
> + /* Re-enable alarm interrupt if a valid alarm was found */
> + if (is_alarm_set)
> + writel(RTC_INT_ALRM, xrtcdev->reg_base + RTC_INT_EN);
> +
> device_init_wakeup(&pdev->dev, true);
>
> return devm_rtc_register_device(xrtcdev->rtc);
> --
> 2.43.0
>
Kindly following up on this patch. I would appreciate it if you could review it when convenient and let me know if any updates are needed.
Thank you for your time.
Best regards,
Harini T
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH V2] rtc: zynqmp: Restore alarm functionality after kexec transition
2025-09-03 15:22 ` T, Harini
@ 2025-09-25 6:04 ` T, Harini
0 siblings, 0 replies; 4+ messages in thread
From: T, Harini @ 2025-09-25 6:04 UTC (permalink / raw)
To: alexandre.belloni, Simek, Michal
Cc: linux-rtc, linux-arm-kernel, linux-kernel, git (AMD-Xilinx)
[Public]
Ping!
> -----Original Message-----
> From: T, Harini
> Sent: Wednesday, September 3, 2025 8:53 PM
> To: Harini T <harini.t@amd.com>; alexandre.belloni@bootlin.com; Simek,
> Michal <michal.simek@amd.com>
> Cc: linux-rtc@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
> kernel@vger.kernel.org; git (AMD-Xilinx) <git@amd.com>
> Subject: RE: [PATCH V2] rtc: zynqmp: Restore alarm functionality after kexec
> transition
>
> Hi Alexandre,
>
> > -----Original Message-----
> > From: Harini T <harini.t@amd.com>
> > Sent: Wednesday, July 30, 2025 7:51 PM
> > To: alexandre.belloni@bootlin.com; Simek, Michal
> > <michal.simek@amd.com>
> > Cc: linux-rtc@vger.kernel.org; linux-arm-kernel@lists.infradead.org;
> > linux- kernel@vger.kernel.org; git (AMD-Xilinx) <git@amd.com>; T,
> > Harini <Harini.T@amd.com>
> > Subject: [PATCH V2] rtc: zynqmp: Restore alarm functionality after
> > kexec transition
> >
> > Caution: This message originated from an External Source. Use proper
> > caution when opening attachments, clicking links, or responding.
> >
> >
> > During kexec reboots, RTC alarms that are fired during the kernel
> > transition experience delayed execution. The new kernel would
> > eventually honor these alarms, but the interrupt handlers would only
> > execute after the driver probe is completed rather than at the intended alarm
> time.
> >
> > This is because pending alarm interrupt status from the previous
> > kernel is not properly cleared during driver initialization, causing
> > timing discrepancies in alarm delivery.
> >
> > To ensure precise alarm timing across kexec transitions, enhance the
> > probe function to:
> > 1. Clear any pending alarm interrupt status from previous boot.
> > 2. Detect existing valid alarms and preserve their state.
> > 3. Re-enable alarm interrupts for future alarms.
> >
> > Signed-off-by: Harini T <harini.t@amd.com>
> > ---
> > Changes in V2:
> > - Remove shutdown handler to prevent alarm interrupts from being
> > disabled during kexec transitions.
> > - Add alarm state detection and restoration in probe.
> >
> > V1 link: https://lore.kernel.org/linux-rtc/20250724170517.974356-1-
> > harini.t@amd.com/T/#u
> > ---
> > drivers/rtc/rtc-zynqmp.c | 19 +++++++++++++++++++
> > 1 file changed, 19 insertions(+)
> >
> > diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c index
> > f39102b66eac..3baa2b481d9f 100644
> > --- a/drivers/rtc/rtc-zynqmp.c
> > +++ b/drivers/rtc/rtc-zynqmp.c
> > @@ -277,6 +277,10 @@ static irqreturn_t xlnx_rtc_interrupt(int irq,
> > void *id) static int xlnx_rtc_probe(struct platform_device *pdev) {
> > struct xlnx_rtc_dev *xrtcdev;
> > + bool is_alarm_set = false;
> > + u32 pending_alrm_irq;
> > + u32 current_time;
> > + u32 alarm_time;
> > int ret;
> >
> > xrtcdev = devm_kzalloc(&pdev->dev, sizeof(*xrtcdev),
> > GFP_KERNEL); @@
> > -296,6 +300,17 @@ static int xlnx_rtc_probe(struct platform_device *pdev)
> > if (IS_ERR(xrtcdev->reg_base))
> > return PTR_ERR(xrtcdev->reg_base);
> >
> > + /* Clear any pending alarm interrupts from previous kernel/boot */
> > + pending_alrm_irq = readl(xrtcdev->reg_base + RTC_INT_STS) &
> > RTC_INT_ALRM;
> > + if (pending_alrm_irq)
> > + writel(pending_alrm_irq, xrtcdev->reg_base +
> > + RTC_INT_STS);
> > +
> > + /* Check if a valid alarm is already set from previous kernel/boot */
> > + alarm_time = readl(xrtcdev->reg_base + RTC_ALRM);
> > + current_time = readl(xrtcdev->reg_base + RTC_CUR_TM);
> > + if (alarm_time > current_time && alarm_time != 0)
> > + is_alarm_set = true;
> > +
> > xrtcdev->alarm_irq = platform_get_irq_byname(pdev, "alarm");
> > if (xrtcdev->alarm_irq < 0)
> > return xrtcdev->alarm_irq; @@ -337,6 +352,10 @@ static
> > int xlnx_rtc_probe(struct platform_device *pdev)
> >
> > xlnx_init_rtc(xrtcdev);
> >
> > + /* Re-enable alarm interrupt if a valid alarm was found */
> > + if (is_alarm_set)
> > + writel(RTC_INT_ALRM, xrtcdev->reg_base + RTC_INT_EN);
> > +
> > device_init_wakeup(&pdev->dev, true);
> >
> > return devm_rtc_register_device(xrtcdev->rtc);
> > --
> > 2.43.0
> >
>
> Kindly following up on this patch. I would appreciate it if you could review it
> when convenient and let me know if any updates are needed.
>
> Thank you for your time.
>
> Best regards,
> Harini T
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2] rtc: zynqmp: Restore alarm functionality after kexec transition
2025-07-30 14:21 [PATCH V2] rtc: zynqmp: Restore alarm functionality after kexec transition Harini T
2025-09-03 15:22 ` T, Harini
@ 2025-10-05 21:23 ` Alexandre Belloni
1 sibling, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2025-10-05 21:23 UTC (permalink / raw)
To: michal.simek, Harini T; +Cc: linux-rtc, linux-arm-kernel, linux-kernel, git
On Wed, 30 Jul 2025 19:51:10 +0530, Harini T wrote:
> During kexec reboots, RTC alarms that are fired during the kernel
> transition experience delayed execution. The new kernel would eventually
> honor these alarms, but the interrupt handlers would only execute after
> the driver probe is completed rather than at the intended alarm time.
>
> This is because pending alarm interrupt status from the previous kernel
> is not properly cleared during driver initialization, causing timing
> discrepancies in alarm delivery.
>
> [...]
Applied, thanks!
[1/1] rtc: zynqmp: Restore alarm functionality after kexec transition
https://git.kernel.org/abelloni/c/e22f4d1321e0
Best regards,
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-05 21:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-30 14:21 [PATCH V2] rtc: zynqmp: Restore alarm functionality after kexec transition Harini T
2025-09-03 15:22 ` T, Harini
2025-09-25 6:04 ` T, Harini
2025-10-05 21:23 ` Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®