Linux-RTC Archive on lore.kernel.org
 help / color / Atom feed
From: "Martin Hundebøll" <martin@geanix.com>
To: linux-rtc@vger.kernel.org
Cc: "Martin Hundebøll" <martin@geanix.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Alessandro Zummo" <a.zummo@towertech.it>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	"Sean Nyekjær" <sean@geanix.com>
Subject: [RFC] rtc: class: register for late suspend / early resume
Date: Wed, 10 Jun 2020 15:24:03 +0200
Message-ID: <20200610132403.2539519-1-martin@geanix.com> (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)
 #else
 #define RTC_CLASS_DEV_PM_OPS	NULL
-- 
2.26.2


       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:
  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=20200610132403.2539519-1-martin@geanix.com \
    --to=martin@geanix.com \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-rtc@vger.kernel.org \
    --cc=sean@geanix.com \
    --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

Linux-RTC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rtc/0 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/ https://lore.kernel.org/linux-rtc \
		linux-rtc@vger.kernel.org
	public-inbox-index linux-rtc

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rtc


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git