diff options
Diffstat (limited to 'kernel/time/timekeeping.c')
-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; |