Linux RTC
 help / color / mirror / Atom feed
* [PATCH 0/2] rtc: interface: keep alarmtimer from sleeping through a minute alarm
@ 2026-12-01 22:18 Igor Velkov via B4 Relay
  2026-12-01 22:18 ` [PATCH 1/2] rtc: interface: let rtc_timer_start() fail for an expired timer Igor Velkov via B4 Relay
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Igor Velkov via B4 Relay @ 2026-12-01 22:18 UTC (permalink / raw)
  To: Alexandre Belloni, John Stultz, Thomas Gleixner
  Cc: Stephen Boyd, Miroslav Lichvar, linux-rtc, linux-kernel, stable,
	Igor Velkov

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@gmail.com

---
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@iav.lv>



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-01 22:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 22:18 [PATCH 0/2] rtc: interface: keep alarmtimer from sleeping through a minute alarm Igor Velkov via B4 Relay
2026-12-01 22:18 ` [PATCH 1/2] rtc: interface: let rtc_timer_start() fail for an expired timer Igor Velkov via B4 Relay
2026-12-01 22:18 ` [PATCH 2/2] rtc: interface: round timer alarms down to the minute Igor Velkov via B4 Relay
2026-12-01 22:23 ` [PATCH 0/2] rtc: interface: keep alarmtimer from sleeping through a minute alarm sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox