Linux-RTC Archive on
 help / color / Atom feed
From: "Martin Hundebøll" <>
Cc: "Martin Hundebøll" <>,
	"Thomas Gleixner" <>,
	"Alessandro Zummo" <>,
	"Alexandre Belloni" <>,
	"Sean Nyekjær" <>
Subject: [RFC] rtc: class: register for late suspend / early resume
Date: Wed, 10 Jun 2020 15:24:03 +0200
Message-ID: <> (raw)
In-Reply-To: <87k10habur.fsf () nanos ! tec ! linutronix ! de>

When running on hardware with no persistent clock, and no non-stop
clocksource, the timekeeping resume code relies on the rtc class to
inject the suspend time.

Other drivers might call into the timekeeping code to sync time in their
devices. If such devices are resumed before the rtc class (and rtc is
the only time source running in suspend) they currently get the
pre-suspend time.

Move the rtc class suspend/resume functions to be called late/early in
the cycle to make sure timekeeping is synchronised when other devices
are resumed.

This works in our case on an i.MX6, where the rtc driver only has
_suspend_noirq()/_resume_noirq(). I imagine it fails with drivers that
has regular _suspend()/_resume() functions. Any hints are welcome.


 drivers/rtc/class.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index 7c88d190c51fc..737b67a1045ab 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -183,7 +183,9 @@ static int rtc_resume(struct device *dev)
 	return 0;
-static SIMPLE_DEV_PM_OPS(rtc_class_dev_pm_ops, rtc_suspend, rtc_resume);
+static const struct dev_pm_ops rtc_class_dev_pm_ops = {
+	SET_LATE_SYSTEM_SLEEP_PM_OPS(rtc_suspend, rtc_resume)
 #define RTC_CLASS_DEV_PM_OPS	(&rtc_class_dev_pm_ops)

       reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87k10habur.fsf () nanos ! tec ! linutronix ! de>
2020-06-10 13:24 ` Martin Hundebøll [this message]
2020-06-29 21:54   ` 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:

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

  git send-email \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-RTC Archive on

Archives are clonable:
	git clone --mirror linux-rtc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rtc linux-rtc/ \
	public-inbox-index linux-rtc

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone