diff options
-rw-r--r-- | kernel/time/timekeeping.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index f682091fa890..4ad79f6bdec6 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -217,6 +217,7 @@ static void change_clocksource(void) | |||
217 | } | 217 | } |
218 | #else | 218 | #else |
219 | static inline void change_clocksource(void) { } | 219 | static inline void change_clocksource(void) { } |
220 | static inline s64 __get_nsec_offset(void) { return 0; } | ||
220 | #endif | 221 | #endif |
221 | 222 | ||
222 | /** | 223 | /** |
@@ -280,6 +281,8 @@ void __init timekeeping_init(void) | |||
280 | static int timekeeping_suspended; | 281 | static int timekeeping_suspended; |
281 | /* time in seconds when suspend began */ | 282 | /* time in seconds when suspend began */ |
282 | static unsigned long timekeeping_suspend_time; | 283 | static unsigned long timekeeping_suspend_time; |
284 | /* xtime offset when we went into suspend */ | ||
285 | static s64 timekeeping_suspend_nsecs; | ||
283 | 286 | ||
284 | /** | 287 | /** |
285 | * timekeeping_resume - Resumes the generic timekeeping subsystem. | 288 | * timekeeping_resume - Resumes the generic timekeeping subsystem. |
@@ -305,6 +308,8 @@ static int timekeeping_resume(struct sys_device *dev) | |||
305 | wall_to_monotonic.tv_sec -= sleep_length; | 308 | wall_to_monotonic.tv_sec -= sleep_length; |
306 | total_sleep_time += sleep_length; | 309 | total_sleep_time += sleep_length; |
307 | } | 310 | } |
311 | /* Make sure that we have the correct xtime reference */ | ||
312 | timespec_add_ns(&xtime, timekeeping_suspend_nsecs); | ||
308 | /* re-base the last cycle value */ | 313 | /* re-base the last cycle value */ |
309 | clock->cycle_last = clocksource_read(clock); | 314 | clock->cycle_last = clocksource_read(clock); |
310 | clock->error = 0; | 315 | clock->error = 0; |
@@ -328,6 +333,8 @@ static int timekeeping_suspend(struct sys_device *dev, pm_message_t state) | |||
328 | timekeeping_suspend_time = read_persistent_clock(); | 333 | timekeeping_suspend_time = read_persistent_clock(); |
329 | 334 | ||
330 | write_seqlock_irqsave(&xtime_lock, flags); | 335 | write_seqlock_irqsave(&xtime_lock, flags); |
336 | /* Get the current xtime offset */ | ||
337 | timekeeping_suspend_nsecs = __get_nsec_offset(); | ||
331 | timekeeping_suspended = 1; | 338 | timekeeping_suspended = 1; |
332 | write_sequnlock_irqrestore(&xtime_lock, flags); | 339 | write_sequnlock_irqrestore(&xtime_lock, flags); |
333 | 340 | ||