aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/kernel/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc/kernel/time.c')
-rw-r--r--arch/sparc/kernel/time.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/arch/sparc/kernel/time.c b/arch/sparc/kernel/time.c
index 6f84fa1b58e5..e10dc831944d 100644
--- a/arch/sparc/kernel/time.c
+++ b/arch/sparc/kernel/time.c
@@ -43,8 +43,6 @@
43#include <asm/pcic.h> 43#include <asm/pcic.h>
44#include <asm/of_device.h> 44#include <asm/of_device.h>
45 45
46extern unsigned long wall_jiffies;
47
48DEFINE_SPINLOCK(rtc_lock); 46DEFINE_SPINLOCK(rtc_lock);
49enum sparc_clock_type sp_clock_typ; 47enum sparc_clock_type sp_clock_typ;
50DEFINE_SPINLOCK(mostek_lock); 48DEFINE_SPINLOCK(mostek_lock);
@@ -449,7 +447,7 @@ unsigned long long sched_clock(void)
449 447
450/* Ok, my cute asm atomicity trick doesn't work anymore. 448/* Ok, my cute asm atomicity trick doesn't work anymore.
451 * There are just too many variables that need to be protected 449 * There are just too many variables that need to be protected
452 * now (both members of xtime, wall_jiffies, et al.) 450 * now (both members of xtime, et al.)
453 */ 451 */
454void do_gettimeofday(struct timeval *tv) 452void do_gettimeofday(struct timeval *tv)
455{ 453{
@@ -459,26 +457,17 @@ void do_gettimeofday(struct timeval *tv)
459 unsigned long max_ntp_tick = tick_usec - tickadj; 457 unsigned long max_ntp_tick = tick_usec - tickadj;
460 458
461 do { 459 do {
462 unsigned long lost;
463
464 seq = read_seqbegin_irqsave(&xtime_lock, flags); 460 seq = read_seqbegin_irqsave(&xtime_lock, flags);
465 usec = do_gettimeoffset(); 461 usec = do_gettimeoffset();
466 lost = jiffies - wall_jiffies;
467 462
468 /* 463 /*
469 * If time_adjust is negative then NTP is slowing the clock 464 * If time_adjust is negative then NTP is slowing the clock
470 * so make sure not to go into next possible interval. 465 * so make sure not to go into next possible interval.
471 * Better to lose some accuracy than have time go backwards.. 466 * Better to lose some accuracy than have time go backwards..
472 */ 467 */
473 if (unlikely(time_adjust < 0)) { 468 if (unlikely(time_adjust < 0))
474 usec = min(usec, max_ntp_tick); 469 usec = min(usec, max_ntp_tick);
475 470
476 if (lost)
477 usec += lost * max_ntp_tick;
478 }
479 else if (unlikely(lost))
480 usec += lost * tick_usec;
481
482 sec = xtime.tv_sec; 471 sec = xtime.tv_sec;
483 usec += (xtime.tv_nsec / 1000); 472 usec += (xtime.tv_nsec / 1000);
484 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags)); 473 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
@@ -521,8 +510,7 @@ static int sbus_do_settimeofday(struct timespec *tv)
521 * wall time. Discover what correction gettimeofday() would have 510 * wall time. Discover what correction gettimeofday() would have
522 * made, and then undo it! 511 * made, and then undo it!
523 */ 512 */
524 nsec -= 1000 * (do_gettimeoffset() + 513 nsec -= 1000 * do_gettimeoffset();
525 (jiffies - wall_jiffies) * (USEC_PER_SEC / HZ));
526 514
527 wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec); 515 wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
528 wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec); 516 wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);