Re: [PATCH] drivers: rtc: handle OTF clock changes
From: Alexandre Belloni
Date: Wed Jun 24 2026 - 11:35:00 EST
On 24/06/2026 15:31:03+0300, Elad Nachman wrote:
> From: Elad Nachman <enachman@xxxxxxxxxxx>
>
> When processing expired RTC events and rearming them, use now
> instead of expiry to prevent endless loops.
> Issue seen with Armada 385 SOC.
The loop is not endless, it may be long however. How do you reproduce
this? Or maybe the question is what is enabling PIE on your system?
Your patch breaks existing code because it will expect to get one event
per elapsed period while your patch will cause events to be skipped.
>
> Fixes commit 6610e0893b8b ("RTC: Rework RTC code to use timerqueue for events")
> Signed-off-by: Elad Nachman <enachman@xxxxxxxxxxx>
> ---
> drivers/rtc/interface.c | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
> index 96626f8068f9..c32ef95a07d4 100644
> --- a/drivers/rtc/interface.c
> +++ b/drivers/rtc/interface.c
> @@ -126,6 +126,7 @@ EXPORT_SYMBOL_GPL(rtc_read_time);
> int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
> {
> int err, uie;
> + struct rtc_time new_tm;
>
> err = rtc_valid_tm(tm);
> if (err != 0)
> @@ -159,6 +160,17 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
> else
> err = -EINVAL;
>
> + if (rtc && rtc->ops && rtc->ops->read_time) {
> + if (!rtc->ops->read_time(rtc->dev.parent, &new_tm)) {
> + pr_debug("new rtc time secs %d mins %d hours %d mday %d mon %d year %d way %d yday %d dst %d\n",
> + new_tm.tm_sec, new_tm.tm_min,
> + new_tm.tm_hour, new_tm.tm_mday,
> + new_tm.tm_mon, new_tm.tm_year,
> + new_tm.tm_wday, new_tm.tm_yday,
> + new_tm.tm_isdst);
> + }
> + }
> +
This is unrelated to the patch.
> pm_stay_awake(rtc->dev.parent);
> mutex_unlock(&rtc->ops_lock);
> /* A timer might have just expired */
> @@ -999,7 +1011,7 @@ void rtc_timer_do_work(struct work_struct *work)
> trace_rtc_timer_fired(timer);
> /* Re-add/fwd periodic timers */
> if (ktime_to_ns(timer->period)) {
> - timer->node.expires = ktime_add(timer->node.expires,
> + timer->node.expires = ktime_add(now,
> timer->period);
> timer->enabled = 1;
> timerqueue_add(&rtc->timerqueue, &timer->node);
> --
> 2.25.1
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com