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 | |
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')
-rw-r--r-- | kernel/posix-timers.c | 2 | ||||
-rw-r--r-- | kernel/time/Kconfig | 5 | ||||
-rw-r--r-- | kernel/time/ntp.c | 16 | ||||
-rw-r--r-- | kernel/time/timekeeping.c | 45 |
4 files changed, 53 insertions, 15 deletions
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index 69185ae6b701..10349d5f2ec3 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c | |||
@@ -997,7 +997,7 @@ SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock, | |||
997 | 997 | ||
998 | err = kc->clock_adj(which_clock, &ktx); | 998 | err = kc->clock_adj(which_clock, &ktx); |
999 | 999 | ||
1000 | if (!err && copy_to_user(utx, &ktx, sizeof(ktx))) | 1000 | if (err >= 0 && copy_to_user(utx, &ktx, sizeof(ktx))) |
1001 | return -EFAULT; | 1001 | return -EFAULT; |
1002 | 1002 | ||
1003 | return err; | 1003 | return err; |
diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig index b69692250af4..24510d84efd7 100644 --- a/kernel/time/Kconfig +++ b/kernel/time/Kconfig | |||
@@ -12,6 +12,11 @@ config CLOCKSOURCE_WATCHDOG | |||
12 | config ARCH_CLOCKSOURCE_DATA | 12 | config ARCH_CLOCKSOURCE_DATA |
13 | bool | 13 | bool |
14 | 14 | ||
15 | # Platforms has a persistent clock | ||
16 | config ALWAYS_USE_PERSISTENT_CLOCK | ||
17 | bool | ||
18 | default n | ||
19 | |||
15 | # Timekeeping vsyscall support | 20 | # Timekeeping vsyscall support |
16 | config GENERIC_TIME_VSYSCALL | 21 | config GENERIC_TIME_VSYSCALL |
17 | bool | 22 | bool |
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 24174b4d669b..313b161504b7 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/time.h> | 15 | #include <linux/time.h> |
16 | #include <linux/mm.h> | 16 | #include <linux/mm.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/rtc.h> | ||
18 | 19 | ||
19 | #include "tick-internal.h" | 20 | #include "tick-internal.h" |
20 | 21 | ||
@@ -483,8 +484,7 @@ out: | |||
483 | return leap; | 484 | return leap; |
484 | } | 485 | } |
485 | 486 | ||
486 | #ifdef CONFIG_GENERIC_CMOS_UPDATE | 487 | #if defined(CONFIG_GENERIC_CMOS_UPDATE) || defined(CONFIG_RTC_SYSTOHC) |
487 | |||
488 | static void sync_cmos_clock(struct work_struct *work); | 488 | static void sync_cmos_clock(struct work_struct *work); |
489 | 489 | ||
490 | static DECLARE_DELAYED_WORK(sync_cmos_work, sync_cmos_clock); | 490 | static DECLARE_DELAYED_WORK(sync_cmos_work, sync_cmos_clock); |
@@ -510,14 +510,22 @@ static void sync_cmos_clock(struct work_struct *work) | |||
510 | } | 510 | } |
511 | 511 | ||
512 | getnstimeofday(&now); | 512 | getnstimeofday(&now); |
513 | if (abs(now.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec / 2) | 513 | if (abs(now.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec / 2) { |
514 | fail = -ENODEV; | ||
515 | #ifdef CONFIG_GENERIC_CMOS_UPDATE | ||
514 | fail = update_persistent_clock(now); | 516 | fail = update_persistent_clock(now); |
517 | #endif | ||
518 | #ifdef CONFIG_RTC_SYSTOHC | ||
519 | if (fail == -ENODEV) | ||
520 | fail = rtc_set_ntp_time(now); | ||
521 | #endif | ||
522 | } | ||
515 | 523 | ||
516 | next.tv_nsec = (NSEC_PER_SEC / 2) - now.tv_nsec - (TICK_NSEC / 2); | 524 | next.tv_nsec = (NSEC_PER_SEC / 2) - now.tv_nsec - (TICK_NSEC / 2); |
517 | if (next.tv_nsec <= 0) | 525 | if (next.tv_nsec <= 0) |
518 | next.tv_nsec += NSEC_PER_SEC; | 526 | next.tv_nsec += NSEC_PER_SEC; |
519 | 527 | ||
520 | if (!fail) | 528 | if (!fail || fail == -ENODEV) |
521 | next.tv_sec = 659; | 529 | next.tv_sec = 659; |
522 | else | 530 | else |
523 | next.tv_sec = 0; | 531 | next.tv_sec = 0; |
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); |