diff options
author | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2009-08-14 09:47:32 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2009-08-15 04:55:47 -0400 |
commit | 23970e389e9cee43c4b41023935e1417271708b2 (patch) | |
tree | d97d299cf74c44cf7ceb4c04c82dafc451fbbfbb /kernel | |
parent | d4f587c67fc39e0030ddd718675e252e208da4d7 (diff) |
timekeeping: Introduce read_boot_clock
Add the new function read_boot_clock to get the exact time the system
has been started. For architectures without support for exact boot
time a new weak function is added that returns 0. Use the exact boot
time to initialize wall_to_monotonic, or xtime if the read_boot_clock
returned 0.
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Acked-by: John Stultz <johnstul@us.ibm.com>
Cc: Daniel Walker <dwalker@fifo99.com>
LKML-Reference: <20090814134811.296703241@de.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/time/timekeeping.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index f1a21ce491e6..15e06defca55 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -501,6 +501,21 @@ void __attribute__((weak)) read_persistent_clock(struct timespec *ts) | |||
501 | ts->tv_nsec = 0; | 501 | ts->tv_nsec = 0; |
502 | } | 502 | } |
503 | 503 | ||
504 | /** | ||
505 | * read_boot_clock - Return time of the system start. | ||
506 | * | ||
507 | * Weak dummy function for arches that do not yet support it. | ||
508 | * Function to read the exact time the system has been started. | ||
509 | * Returns a timespec with tv_sec=0 and tv_nsec=0 if unsupported. | ||
510 | * | ||
511 | * XXX - Do be sure to remove it once all arches implement it. | ||
512 | */ | ||
513 | void __attribute__((weak)) read_boot_clock(struct timespec *ts) | ||
514 | { | ||
515 | ts->tv_sec = 0; | ||
516 | ts->tv_nsec = 0; | ||
517 | } | ||
518 | |||
504 | /* | 519 | /* |
505 | * timekeeping_init - Initializes the clocksource and common timekeeping values | 520 | * timekeeping_init - Initializes the clocksource and common timekeeping values |
506 | */ | 521 | */ |
@@ -508,9 +523,10 @@ void __init timekeeping_init(void) | |||
508 | { | 523 | { |
509 | struct clocksource *clock; | 524 | struct clocksource *clock; |
510 | unsigned long flags; | 525 | unsigned long flags; |
511 | struct timespec now; | 526 | struct timespec now, boot; |
512 | 527 | ||
513 | read_persistent_clock(&now); | 528 | read_persistent_clock(&now); |
529 | read_boot_clock(&boot); | ||
514 | 530 | ||
515 | write_seqlock_irqsave(&xtime_lock, flags); | 531 | write_seqlock_irqsave(&xtime_lock, flags); |
516 | 532 | ||
@@ -525,8 +541,12 @@ void __init timekeeping_init(void) | |||
525 | xtime.tv_nsec = now.tv_nsec; | 541 | xtime.tv_nsec = now.tv_nsec; |
526 | raw_time.tv_sec = 0; | 542 | raw_time.tv_sec = 0; |
527 | raw_time.tv_nsec = 0; | 543 | raw_time.tv_nsec = 0; |
544 | if (boot.tv_sec == 0 && boot.tv_nsec == 0) { | ||
545 | boot.tv_sec = xtime.tv_sec; | ||
546 | boot.tv_nsec = xtime.tv_nsec; | ||
547 | } | ||
528 | set_normalized_timespec(&wall_to_monotonic, | 548 | set_normalized_timespec(&wall_to_monotonic, |
529 | -xtime.tv_sec, -xtime.tv_nsec); | 549 | -boot.tv_sec, -boot.tv_nsec); |
530 | update_xtime_cache(0); | 550 | update_xtime_cache(0); |
531 | total_sleep_time.tv_sec = 0; | 551 | total_sleep_time.tv_sec = 0; |
532 | total_sleep_time.tv_nsec = 0; | 552 | total_sleep_time.tv_nsec = 0; |