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