* [RFC] rtc: class: register for late suspend / early resume [not found] <87k10habur.fsf () nanos ! tec ! linutronix ! de> @ 2020-06-10 13:24 ` Martin Hundebøll 2020-06-29 21:54 ` Alexandre Belloni 0 siblings, 1 reply; 2+ messages in thread From: Martin Hundebøll @ 2020-06-10 13:24 UTC (permalink / raw) To: linux-rtc Cc: Martin Hundebøll, Thomas Gleixner, Alessandro Zummo, Alexandre Belloni, Sean Nyekjær 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 ^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [RFC] rtc: class: register for late suspend / early resume 2020-06-10 13:24 ` [RFC] rtc: class: register for late suspend / early resume Martin Hundebøll @ 2020-06-29 21:54 ` Alexandre Belloni 0 siblings, 0 replies; 2+ messages in thread From: Alexandre Belloni @ 2020-06-29 21:54 UTC (permalink / raw) To: Martin Hundebøll Cc: linux-rtc, Thomas Gleixner, Alessandro Zummo, Sean Nyekjær Hi, On 10/06/2020 15:24:03+0200, Martin Hundebøll wrote: > 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. > Just to let you know that I've seen the previous thread and also this patch. I'm not sure about the patch, especially regarding RTCs on an i2c or SPI bus were wee need the bus to be suspended after the RTC and resumed before the RTC. The order is properly handled when using but I need to check whether it is correct when using _late. I remember having issues with that with regulators. I must admit my time is a bit scarce right now. Maybe you can get input from the PM guys? Regards, -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-29 21:54 UTC | newest] Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <87k10habur.fsf () nanos ! tec ! linutronix ! de> 2020-06-10 13:24 ` [RFC] rtc: class: register for late suspend / early resume Martin Hundebøll 2020-06-29 21:54 ` Alexandre Belloni
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).