[PATCH 0/2] rtc: interface: keep alarmtimer from sleeping through a minute alarm

From: Igor Velkov via B4 Relay

Date: Tue Dec 01 2026 - 17:18:54 EST


On an RTC with minute alarm resolution, the alarm wakes the system up to
59 seconds before the timer is due. Suspending again for the rest of the
interval, as autosleep does, then loses the timer: alarmtimer_suspend()
programs the same minute, the alarm registers keep their value, and the
RTC raises no new alarm.

Patch 1 lets rtc_timer_start() return -ETIME for an expiry that has
already passed, so that alarmtimer_suspend() rejects the suspend as it
means to. Patch 2 rounds the expiry down to the minute, as rtc_set_alarm()
does, so that an expiry in the current minute counts as passed.

This follows Alexandre's reply to Arun's patch for the rtc_set_alarm()
path [1]: never round up, and let the caller handle the error.
alarmtimer_suspend() already handles it, but never got it.

Tested on an ODROID-HC4 with a PCF8563, s2idle, v7.4-rc5, with meson-vrtc
left out so that alarmtimer uses the PCF8563:
- minute alarm wakes early, system goes back to sleep at once: before,
no wakeup and the timer 105 s late; after, the second suspend is
rejected and the timer fires on time
- timer in the current minute: suspend rejected, timer on time
- timer in a later minute: wakes at the start of that minute, as before

[1] https://lore.kernel.org/r/20261110-rtc-minute-alarm-v1-1-be9d7c5227a1@xxxxxxxxx

---
Igor Velkov (2):
rtc: interface: let rtc_timer_start() fail for an expired timer
rtc: interface: round timer alarms down to the minute

drivers/rtc/interface.c | 38 +++++++++++++++++++++++++++++++++-----
1 file changed, 33 insertions(+), 5 deletions(-)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261201-b4-rtc-timer-round-down-2145182e3ac9

Best regards,
--
Igor Velkov <iav@xxxxxx>