From 3271736784253fe68ccb46ec2320066f70ceecb6 Mon Sep 17 00:00:00 2001
From: Andrew Morton <akpm@osdl.org>
Date: Wed, 2 Jul 2003 08:49:14 -0700
Subject: [PATCH] [PATCH] fix lost-tick compensation corner-case

From: john stultz <johnstul@us.ibm.com>

This patch catches a corner case in the lost-tick compensation code.

There is a check to see if we overflowed between reads of the two time
sources, however should the high res time source be slightly slower then
what we calibrated, its possible to trigger this code when no ticks have
been lost.

This patch adds an extra check to insure we have seen more then one tick
before we check for this overflow.  This seems to resolve the remaining
"time doubling" issues that I've seen reported.
---
 arch/i386/kernel/timers/timer_cyclone.c | 2 +-
 arch/i386/kernel/timers/timer_tsc.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/i386/kernel/timers/timer_cyclone.c b/arch/i386/kernel/timers/timer_cyclone.c
index 0d2c2baf2a64..f8b55ffd229d 100644
--- a/arch/i386/kernel/timers/timer_cyclone.c
+++ b/arch/i386/kernel/timers/timer_cyclone.c
@@ -88,7 +88,7 @@ static void mark_offset_cyclone(void)
 	 * between cyclone and pit reads (as noted when 
 	 * usec delta is > 90% # of usecs/tick)
 	 */
-	if (abs(delay - delay_at_last_interrupt) > (900000/HZ)) 
+	if (lost && abs(delay - delay_at_last_interrupt) > (900000/HZ))
 		jiffies++;
 }
 
diff --git a/arch/i386/kernel/timers/timer_tsc.c b/arch/i386/kernel/timers/timer_tsc.c
index e89d8da8e49b..95a62acf713a 100644
--- a/arch/i386/kernel/timers/timer_tsc.c
+++ b/arch/i386/kernel/timers/timer_tsc.c
@@ -205,7 +205,7 @@ static void mark_offset_tsc(void)
 	 * between tsc and pit reads (as noted when 
 	 * usec delta is > 90% # of usecs/tick)
 	 */
-	if (abs(delay - delay_at_last_interrupt) > (900000/HZ))
+	if (lost && abs(delay - delay_at_last_interrupt) > (900000/HZ))
 		jiffies++;
 }
 
-- 
2.30.9