diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2013-02-04 05:03:03 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2013-02-04 05:03:03 -0500 |
commit | 90889a635a9b5488624bccce3ff6b2eec68c007b (patch) | |
tree | 8ddde1e04060bd65ca2aafb09b38066cb7d69b4d /kernel/time/timekeeping.c | |
parent | a9037430c6c784165a940a90bcd29f886834c8e7 (diff) | |
parent | 6f16eebe1ff82176339a0439c98ebec9768b0ee2 (diff) |
Merge branch 'fortglx/3.9/time' of git://git.linaro.org/people/jstultz/linux into timers/core
Trivial conflict in arch/x86/Kconfig
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/time/timekeeping.c')
-rw-r--r-- | kernel/time/timekeeping.c | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index cbc6acb0db3f..1e35515a875e 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -29,6 +29,9 @@ static struct timekeeper timekeeper; | |||
29 | /* flag for if timekeeping is suspended */ | 29 | /* flag for if timekeeping is suspended */ |
30 | int __read_mostly timekeeping_suspended; | 30 | int __read_mostly timekeeping_suspended; |
31 | 31 | ||
32 | /* Flag for if there is a persistent clock on this platform */ | ||
33 | bool __read_mostly persistent_clock_exist = false; | ||
34 | |||
32 | static inline void tk_normalize_xtime(struct timekeeper *tk) | 35 | static inline void tk_normalize_xtime(struct timekeeper *tk) |
33 | { | 36 | { |
34 | while (tk->xtime_nsec >= ((u64)NSEC_PER_SEC << tk->shift)) { | 37 | while (tk->xtime_nsec >= ((u64)NSEC_PER_SEC << tk->shift)) { |
@@ -264,19 +267,18 @@ static void timekeeping_forward_now(struct timekeeper *tk) | |||
264 | } | 267 | } |
265 | 268 | ||
266 | /** | 269 | /** |
267 | * getnstimeofday - Returns the time of day in a timespec | 270 | * __getnstimeofday - Returns the time of day in a timespec. |
268 | * @ts: pointer to the timespec to be set | 271 | * @ts: pointer to the timespec to be set |
269 | * | 272 | * |
270 | * Returns the time of day in a timespec. | 273 | * Updates the time of day in the timespec. |
274 | * Returns 0 on success, or -ve when suspended (timespec will be undefined). | ||
271 | */ | 275 | */ |
272 | void getnstimeofday(struct timespec *ts) | 276 | int __getnstimeofday(struct timespec *ts) |
273 | { | 277 | { |
274 | struct timekeeper *tk = &timekeeper; | 278 | struct timekeeper *tk = &timekeeper; |
275 | unsigned long seq; | 279 | unsigned long seq; |
276 | s64 nsecs = 0; | 280 | s64 nsecs = 0; |
277 | 281 | ||
278 | WARN_ON(timekeeping_suspended); | ||
279 | |||
280 | do { | 282 | do { |
281 | seq = read_seqbegin(&tk->lock); | 283 | seq = read_seqbegin(&tk->lock); |
282 | 284 | ||
@@ -287,6 +289,26 @@ void getnstimeofday(struct timespec *ts) | |||
287 | 289 | ||
288 | ts->tv_nsec = 0; | 290 | ts->tv_nsec = 0; |
289 | timespec_add_ns(ts, nsecs); | 291 | timespec_add_ns(ts, nsecs); |
292 | |||
293 | /* | ||
294 | * Do not bail out early, in case there were callers still using | ||
295 | * the value, even in the face of the WARN_ON. | ||
296 | */ | ||
297 | if (unlikely(timekeeping_suspended)) | ||
298 | return -EAGAIN; | ||
299 | return 0; | ||
300 | } | ||
301 | EXPORT_SYMBOL(__getnstimeofday); | ||
302 | |||
303 | /** | ||
304 | * getnstimeofday - Returns the time of day in a timespec. | ||
305 | * @ts: pointer to the timespec to be set | ||
306 | * | ||
307 | * Returns the time of day in a timespec (WARN if suspended). | ||
308 | */ | ||
309 | void getnstimeofday(struct timespec *ts) | ||
310 | { | ||
311 | WARN_ON(__getnstimeofday(ts)); | ||
290 | } | 312 | } |
291 | EXPORT_SYMBOL(getnstimeofday); | 313 | EXPORT_SYMBOL(getnstimeofday); |
292 | 314 | ||
@@ -640,12 +662,14 @@ void __init timekeeping_init(void) | |||
640 | struct timespec now, boot, tmp; | 662 | struct timespec now, boot, tmp; |
641 | 663 | ||
642 | read_persistent_clock(&now); | 664 | read_persistent_clock(&now); |
665 | |||
643 | if (!timespec_valid_strict(&now)) { | 666 | if (!timespec_valid_strict(&now)) { |
644 | pr_warn("WARNING: Persistent clock returned invalid value!\n" | 667 | pr_warn("WARNING: Persistent clock returned invalid value!\n" |
645 | " Check your CMOS/BIOS settings.\n"); | 668 | " Check your CMOS/BIOS settings.\n"); |
646 | now.tv_sec = 0; | 669 | now.tv_sec = 0; |
647 | now.tv_nsec = 0; | 670 | now.tv_nsec = 0; |
648 | } | 671 | } else if (now.tv_sec || now.tv_nsec) |
672 | persistent_clock_exist = true; | ||
649 | 673 | ||
650 | read_boot_clock(&boot); | 674 | read_boot_clock(&boot); |
651 | if (!timespec_valid_strict(&boot)) { | 675 | if (!timespec_valid_strict(&boot)) { |
@@ -718,11 +742,12 @@ void timekeeping_inject_sleeptime(struct timespec *delta) | |||
718 | { | 742 | { |
719 | struct timekeeper *tk = &timekeeper; | 743 | struct timekeeper *tk = &timekeeper; |
720 | unsigned long flags; | 744 | unsigned long flags; |
721 | struct timespec ts; | ||
722 | 745 | ||
723 | /* Make sure we don't set the clock twice */ | 746 | /* |
724 | read_persistent_clock(&ts); | 747 | * Make sure we don't set the clock twice, as timekeeping_resume() |
725 | if (!(ts.tv_sec == 0 && ts.tv_nsec == 0)) | 748 | * already did it |
749 | */ | ||
750 | if (has_persistent_clock()) | ||
726 | return; | 751 | return; |
727 | 752 | ||
728 | write_seqlock_irqsave(&tk->lock, flags); | 753 | write_seqlock_irqsave(&tk->lock, flags); |