From: Herbert Poetzl <herbert@13thfloor.at>

hopefully 'better' fix for broken Intel Mercury/Neptune in
wait_8254_wraparound() ...

Rationale:

changing HZ to higher values (like 5k,10k or 20k) will hang machines using
wait_8254_wraparound() indefinitely, because a suboptimal workaround for
buggy Intel Mercury/Neptune chipsets is in place.

this was tested on several machines, unfortunately none with a broken Intel
Mercury/Neptune chipset, and it works fine with various HZ values ...

Signed-off-by: Herbert Pƶtzl <herbert@13thfloor.at>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/i386/kernel/apic.c |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

diff -puN arch/i386/kernel/apic.c~improved-wait_8254_wraparound arch/i386/kernel/apic.c
--- 25/arch/i386/kernel/apic.c~improved-wait_8254_wraparound	Thu Jan  6 15:37:42 2005
+++ 25-akpm/arch/i386/kernel/apic.c	Thu Jan  6 15:37:42 2005
@@ -877,23 +877,18 @@ static unsigned int __init get_8254_time
 /* next tick in 8254 can be caught by catching timer wraparound */
 static void __init wait_8254_wraparound(void)
 {
-	unsigned int curr_count, prev_count=~0;
-	int delta;
+	unsigned int curr_count, prev_count;
 
 	curr_count = get_8254_timer_count();
-
 	do {
 		prev_count = curr_count;
 		curr_count = get_8254_timer_count();
-		delta = curr_count-prev_count;
 
-	/*
-	 * This limit for delta seems arbitrary, but it isn't, it's
-	 * slightly above the level of error a buggy Mercury/Neptune
-	 * chipset timer can cause.
-	 */
+		/* workaround for broken Mercury/Neptune */
+		if (prev_count >= curr_count + 0x100)
+			curr_count = get_8254_timer_count();
 
-	} while (delta < 300);
+	} while (prev_count >= curr_count);
 }
 
 /*
_