diff options
Diffstat (limited to 'arch/mips/kernel/time.c')
-rw-r--r-- | arch/mips/kernel/time.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c index 7050b4ffffcd..51273b7297a7 100644 --- a/arch/mips/kernel/time.c +++ b/arch/mips/kernel/time.c | |||
@@ -163,7 +163,7 @@ void do_gettimeofday(struct timeval *tv) | |||
163 | unsigned long seq; | 163 | unsigned long seq; |
164 | unsigned long lost; | 164 | unsigned long lost; |
165 | unsigned long usec, sec; | 165 | unsigned long usec, sec; |
166 | unsigned long max_ntp_tick = tick_usec - tickadj; | 166 | unsigned long max_ntp_tick; |
167 | 167 | ||
168 | do { | 168 | do { |
169 | seq = read_seqbegin(&xtime_lock); | 169 | seq = read_seqbegin(&xtime_lock); |
@@ -178,12 +178,13 @@ void do_gettimeofday(struct timeval *tv) | |||
178 | * Better to lose some accuracy than have time go backwards.. | 178 | * Better to lose some accuracy than have time go backwards.. |
179 | */ | 179 | */ |
180 | if (unlikely(time_adjust < 0)) { | 180 | if (unlikely(time_adjust < 0)) { |
181 | max_ntp_tick = (USEC_PER_SEC / HZ) - tickadj; | ||
181 | usec = min(usec, max_ntp_tick); | 182 | usec = min(usec, max_ntp_tick); |
182 | 183 | ||
183 | if (lost) | 184 | if (lost) |
184 | usec += lost * max_ntp_tick; | 185 | usec += lost * max_ntp_tick; |
185 | } else if (unlikely(lost)) | 186 | } else if (unlikely(lost)) |
186 | usec += lost * tick_usec; | 187 | usec += lost * (USEC_PER_SEC / HZ); |
187 | 188 | ||
188 | sec = xtime.tv_sec; | 189 | sec = xtime.tv_sec; |
189 | usec += (xtime.tv_nsec / 1000); | 190 | usec += (xtime.tv_nsec / 1000); |
@@ -423,6 +424,8 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
423 | unsigned long j; | 424 | unsigned long j; |
424 | unsigned int count; | 425 | unsigned int count; |
425 | 426 | ||
427 | write_seqlock(&xtime_lock); | ||
428 | |||
426 | count = mips_hpt_read(); | 429 | count = mips_hpt_read(); |
427 | mips_timer_ack(); | 430 | mips_timer_ack(); |
428 | 431 | ||
@@ -440,7 +443,6 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
440 | * CMOS clock accordingly every ~11 minutes. rtc_set_time() has to be | 443 | * CMOS clock accordingly every ~11 minutes. rtc_set_time() has to be |
441 | * called as close as possible to 500 ms before the new second starts. | 444 | * called as close as possible to 500 ms before the new second starts. |
442 | */ | 445 | */ |
443 | write_seqlock(&xtime_lock); | ||
444 | if (ntp_synced() && | 446 | if (ntp_synced() && |
445 | xtime.tv_sec > last_rtc_update + 660 && | 447 | xtime.tv_sec > last_rtc_update + 660 && |
446 | (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 && | 448 | (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 && |
@@ -452,7 +454,6 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
452 | last_rtc_update = xtime.tv_sec - 600; | 454 | last_rtc_update = xtime.tv_sec - 600; |
453 | } | 455 | } |
454 | } | 456 | } |
455 | write_sequnlock(&xtime_lock); | ||
456 | 457 | ||
457 | /* | 458 | /* |
458 | * If jiffies has overflown in this timer_interrupt, we must | 459 | * If jiffies has overflown in this timer_interrupt, we must |
@@ -495,6 +496,8 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
495 | } | 496 | } |
496 | } | 497 | } |
497 | 498 | ||
499 | write_sequnlock(&xtime_lock); | ||
500 | |||
498 | /* | 501 | /* |
499 | * In UP mode, we call local_timer_interrupt() to do profiling | 502 | * In UP mode, we call local_timer_interrupt() to do profiling |
500 | * and process accouting. | 503 | * and process accouting. |