The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>,
	John Stultz <jstultz@google.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
	Thomas Gleixner <tglx@linutronix.de>,
	Stephen Boyd <sboyd@kernel.org>,
	linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Brian Norris <briannorris@chromium.org>,
	Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH v2 0/2] rtc: alarmtimer: Use maximum alarm time offset
Date: Fri, 15 Sep 2023 08:22:36 -0700	[thread overview]
Message-ID: <20230915152238.1144706-1-linux@roeck-us.net> (raw)

Some userspace applications use timerfd_create() to request wakeups after
a long period of time. For example, a backup application may request a
wakeup once per week. This is perfectly fine as long as the system does
not try to suspend. However, if the system tries to suspend and the
system's RTC does not support the required alarm timeout, the suspend
operation will fail with an error such as

rtc_cmos 00:01: Alarms can be up to one day in the future
PM: dpm_run_callback(): platform_pm_suspend+0x0/0x4a returns -22
alarmtimer alarmtimer.4.auto: platform_pm_suspend+0x0/0x4a returned -22 after 117 usecs
PM: Device alarmtimer.4.auto failed to suspend: error -22

This results in a refusal to suspend the system, causing substantial
battery drain on affected systems.

To fix the problem, use the maximum alarm time offset as reported by rtc
drivers to set the maximum alarm time. While this may result in early
wakeups from suspend, it is still much better than not suspending at all.

This patch series standardizes system behavior if the requested alarm
timeout is larger than the alarm timeout supported by the rtc chip.
Currently, in this situation, the rtc driver will do one of the following.
- It may return an error.
- It may limit the alarm timeout to the maximum supported by the rtc chip.
- It may mask the timeout by the maximum alarm timeout supported by the RTC
  chip (i.e. a requested timeout of 1 day + 1 minute may result in a 1
  minute timeout).

With this series in place, if the rtc driver reports the maximum alarm
timeout supported by the rtc chip, the system will always limit the alarm
timeout to the maximum supported by the rtc chip.

The first patch of the series adds support for an API function which returns
the maximum of the requested alarm timeout and the alarm timeout supported
by the RTC chip. The second patch uses that value in the alarmtimer code
to set the maximum wake-up time from system suspend.

Version 1 of the series added support for storing the maximum alarm timeout
to the rtc core. This series is based on the original series, most of which
is now in the upstream kernel. It adds an API function to the rtc core and
uses that function in the alarm timer code to set the alarm time. It
replaces patch 2/7 ("rtc: alarmtimer: Use maximum alarm time offset") of
the original series.

v1:
    <fixme>

----------------------------------------------------------------
Guenter Roeck (2):
      rtc: Add API function to return alarm time bound by rtc limit
      rtc: alarmtimer: Use maximum alarm time offset

 include/linux/rtc.h      | 17 +++++++++++++++++
 kernel/time/alarmtimer.c | 11 +++++++++++
 2 files changed, 28 insertions(+)

             reply	other threads:[~2023-09-15 15:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-15 15:22 Guenter Roeck [this message]
2023-09-15 15:22 ` [PATCH v2 1/2] rtc: Add API function to return alarm time bound by rtc limit Guenter Roeck
2023-10-09 13:08   ` [tip: timers/core] rtc: Add API function to return alarm time bound by hardware limit tip-bot2 for Guenter Roeck
2023-09-15 15:22 ` [PATCH 2/2] rtc: alarmtimer: Use maximum alarm time offset Guenter Roeck
2023-09-15 17:42   ` John Stultz
2023-10-09 13:08   ` [tip: timers/core] alarmtimer: Use maximum alarm time for suspend tip-bot2 for Guenter Roeck
2023-10-30  0:44 ` [PATCH v2 0/2] rtc: alarmtimer: Use maximum alarm time offset Alexandre Belloni
2023-10-30  1:00   ` Alexandre Belloni

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=20230915152238.1144706-1-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=briannorris@chromium.org \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    /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