]> git.neil.brown.name Git - history.git/commitdiff
[SPARC]: Port over cset 1.1459 x86 gettimeofday fix.
authorDavid S. Miller <davem@nuts.ninka.net>
Wed, 19 Nov 2003 09:30:27 +0000 (01:30 -0800)
committerDavid S. Miller <davem@nuts.ninka.net>
Wed, 19 Nov 2003 09:30:27 +0000 (01:30 -0800)
arch/sparc/kernel/pcic.c
arch/sparc/kernel/time.c
arch/sparc64/kernel/time.c

index 3bb97b4771bdc8a8753bd6be0565215b6eaf4fdd..d03654e646468777f302d183324710bb857bac4f 100644 (file)
@@ -776,23 +776,28 @@ static void pci_do_gettimeofday(struct timeval *tv)
        unsigned long flags;
        unsigned long seq;
        unsigned long usec, sec;
+       unsigned long max_ntp_tick = tick_usec - tickadj;
 
        do {
+               unsigned long lost;
+
                seq = read_seqbegin_irqsave(&xtime_lock, flags);
                usec = do_gettimeoffset();
-               {
-                       unsigned long lost = jiffies - wall_jiffies;
-                       if (lost)
-                               usec += lost * (1000000 / HZ);
-               }
+               lost = jiffies - wall_jiffies;
 
                /*
                 * If time_adjust is negative then NTP is slowing the clock
                 * so make sure not to go into next possible interval.
                 * Better to lose some accuracy than have time go backwards..
                 */
-               if (unlikely(time_adjust < 0) && usec > tickadj)
-                       usec = tickadj;
+               if (unlikely(time_adjust < 0)) {
+                       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;
                usec += (xtime.tv_nsec / 1000);
index 5566ad8a751ba57f574650dc9b938bf7d78caa21..20ba51723a400cb3a8f8ab17fefe52ce8968b83c 100644 (file)
@@ -481,23 +481,28 @@ void do_gettimeofday(struct timeval *tv)
        unsigned long flags;
        unsigned long seq;
        unsigned long usec, sec;
+       unsigned long max_ntp_tick = tick_usec - tickadj;
 
        do {
+               unsigned long lost;
+
                seq = read_seqbegin_irqsave(&xtime_lock, flags);
                usec = do_gettimeoffset();
-               {
-                       unsigned long lost = jiffies - wall_jiffies;
-                       if (lost)
-                               usec += lost * (1000000 / HZ);
-               }
+               lost = jiffies - wall_jiffies;
 
                /*
                 * If time_adjust is negative then NTP is slowing the clock
                 * so make sure not to go into next possible interval.
                 * Better to lose some accuracy than have time go backwards..
                 */
-               if (unlikely(time_adjust < 0) && usec > tickadj)
-                       usec = tickadj;
+               if (unlikely(time_adjust < 0)) {
+                       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;
                usec += (xtime.tv_nsec / 1000);
index d06bcc0562f132fbed930601fd5f4e2af0ba180d..e368409323d9cc91651b30db8e430d6fc8bf8806 100644 (file)
@@ -1140,23 +1140,28 @@ void do_gettimeofday(struct timeval *tv)
        unsigned long flags;
        unsigned long seq;
        unsigned long usec, sec;
+       unsigned long max_ntp_tick = tick_usec - tickadj;
 
        do {
+               unsigned long lost;
+
                seq = read_seqbegin_irqsave(&xtime_lock, flags);
                usec = do_gettimeoffset();
-               {
-                       unsigned long lost = jiffies - wall_jiffies;
-                       if (lost)
-                               usec += lost * (1000000 / HZ);
-               }
+               lost = jiffies - wall_jiffies;
 
                /*
                 * If time_adjust is negative then NTP is slowing the clock
                 * so make sure not to go into next possible interval.
                 * Better to lose some accuracy than have time go backwards..
                 */
-               if (unlikely(time_adjust < 0) && usec > tickadj)
-                       usec = tickadj;
+               if (unlikely(time_adjust < 0)) {
+                       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;
                usec += (xtime.tv_nsec / 1000);