Commit b162fa01 authored by David S. Miller's avatar David S. Miller

[SPARC]: Port over cset 1.1459 x86 gettimeofday fix.

parent 44cb023a
...@@ -776,23 +776,28 @@ static void pci_do_gettimeofday(struct timeval *tv) ...@@ -776,23 +776,28 @@ static void pci_do_gettimeofday(struct timeval *tv)
unsigned long flags; unsigned long flags;
unsigned long seq; unsigned long seq;
unsigned long usec, sec; unsigned long usec, sec;
unsigned long max_ntp_tick = tick_usec - tickadj;
do { do {
unsigned long lost;
seq = read_seqbegin_irqsave(&xtime_lock, flags); seq = read_seqbegin_irqsave(&xtime_lock, flags);
usec = do_gettimeoffset(); usec = do_gettimeoffset();
{ lost = jiffies - wall_jiffies;
unsigned long lost = jiffies - wall_jiffies;
if (lost)
usec += lost * (1000000 / HZ);
}
/* /*
* If time_adjust is negative then NTP is slowing the clock * If time_adjust is negative then NTP is slowing the clock
* so make sure not to go into next possible interval. * so make sure not to go into next possible interval.
* Better to lose some accuracy than have time go backwards.. * Better to lose some accuracy than have time go backwards..
*/ */
if (unlikely(time_adjust < 0) && usec > tickadj) if (unlikely(time_adjust < 0)) {
usec = tickadj; usec = min(usec, max_ntp_tick);
if (lost)
usec += lost * max_ntp_tick;
}
else if (unlikely(lost))
usec += lost * tick_usec;
sec = xtime.tv_sec; sec = xtime.tv_sec;
usec += (xtime.tv_nsec / 1000); usec += (xtime.tv_nsec / 1000);
......
...@@ -481,23 +481,28 @@ void do_gettimeofday(struct timeval *tv) ...@@ -481,23 +481,28 @@ void do_gettimeofday(struct timeval *tv)
unsigned long flags; unsigned long flags;
unsigned long seq; unsigned long seq;
unsigned long usec, sec; unsigned long usec, sec;
unsigned long max_ntp_tick = tick_usec - tickadj;
do { do {
unsigned long lost;
seq = read_seqbegin_irqsave(&xtime_lock, flags); seq = read_seqbegin_irqsave(&xtime_lock, flags);
usec = do_gettimeoffset(); usec = do_gettimeoffset();
{ lost = jiffies - wall_jiffies;
unsigned long lost = jiffies - wall_jiffies;
if (lost)
usec += lost * (1000000 / HZ);
}
/* /*
* If time_adjust is negative then NTP is slowing the clock * If time_adjust is negative then NTP is slowing the clock
* so make sure not to go into next possible interval. * so make sure not to go into next possible interval.
* Better to lose some accuracy than have time go backwards.. * Better to lose some accuracy than have time go backwards..
*/ */
if (unlikely(time_adjust < 0) && usec > tickadj) if (unlikely(time_adjust < 0)) {
usec = tickadj; usec = min(usec, max_ntp_tick);
if (lost)
usec += lost * max_ntp_tick;
}
else if (unlikely(lost))
usec += lost * tick_usec;
sec = xtime.tv_sec; sec = xtime.tv_sec;
usec += (xtime.tv_nsec / 1000); usec += (xtime.tv_nsec / 1000);
......
...@@ -1140,23 +1140,28 @@ void do_gettimeofday(struct timeval *tv) ...@@ -1140,23 +1140,28 @@ void do_gettimeofday(struct timeval *tv)
unsigned long flags; unsigned long flags;
unsigned long seq; unsigned long seq;
unsigned long usec, sec; unsigned long usec, sec;
unsigned long max_ntp_tick = tick_usec - tickadj;
do { do {
unsigned long lost;
seq = read_seqbegin_irqsave(&xtime_lock, flags); seq = read_seqbegin_irqsave(&xtime_lock, flags);
usec = do_gettimeoffset(); usec = do_gettimeoffset();
{ lost = jiffies - wall_jiffies;
unsigned long lost = jiffies - wall_jiffies;
if (lost)
usec += lost * (1000000 / HZ);
}
/* /*
* If time_adjust is negative then NTP is slowing the clock * If time_adjust is negative then NTP is slowing the clock
* so make sure not to go into next possible interval. * so make sure not to go into next possible interval.
* Better to lose some accuracy than have time go backwards.. * Better to lose some accuracy than have time go backwards..
*/ */
if (unlikely(time_adjust < 0) && usec > tickadj) if (unlikely(time_adjust < 0)) {
usec = tickadj; usec = min(usec, max_ntp_tick);
if (lost)
usec += lost * max_ntp_tick;
}
else if (unlikely(lost))
usec += lost * tick_usec;
sec = xtime.tv_sec; sec = xtime.tv_sec;
usec += (xtime.tv_nsec / 1000); usec += (xtime.tv_nsec / 1000);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment