mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Igor Velkov via B4 Relay <devnull+iav.iav.lv@kernel.org>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>,
	 John Stultz <jstultz@google.com>,
	Thomas Gleixner <tglx@kernel.org>
Cc: Stephen Boyd <sboyd@kernel.org>,
	Miroslav Lichvar <mlichvar@redhat.com>,
	 linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org,
	 stable@vger.kernel.org, Igor Velkov <iav@iav.lv>
Subject: [PATCH 0/2] rtc: interface: keep alarmtimer from sleeping through a minute alarm
Date: Tue, 01 Dec 2026 22:18:39 +0000	[thread overview]
Message-ID: <20261201-b4-rtc-timer-round-down-v1-0-4ac60b362a54@iav.lv> (raw)

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>



             reply	other threads:[~2026-12-01 22:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 22:18 Igor Velkov via B4 Relay [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201-b4-rtc-timer-round-down-v1-0-4ac60b362a54@iav.lv \
    --to=devnull+iav.iav.lv@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=iav@iav.lv \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=mlichvar@redhat.com \
    --cc=sboyd@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®