Skip to contentSkip to conversation

failsafe mechanism to HPET clock calibration

PATCH In review Ravikiran G Thirumalai 2 participants 2 messages Apr 13, 2007 – Apr 14, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 failsafe mechanism to HPET clock calibration

Provide a failsafe mechanism to avoid kernel spinning for ever at read_hpet_tsc during early kernel bootup.

This failsafe mechanism was introduced in 21-rc,
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=2f7a2a79c3ebb44f8b1b7d9b4fd3a650eb69e544

But looks like the hpet split from time.c lost the commit.

This patch reintroduces the failsafe mechanism

arch/x86_64/kernel/hpet.c +6 -3
Index: linux-2.6.21-rc5/arch/x86_64/kernel/hpet.c
===================================================================
@@ -191,6 +191,7 @@ int hpet_reenable(void)
 
 #define TICK_COUNT 100000000
 #define TICK_MIN   5000
+#define MAX_TRIES  5
 
 /*
  * Some platforms take periodic SMI interrupts with 5ms duration. Make sure none
@@ -198,13 +199,15 @@ int hpet_reenable(void)
  */
 static void __init read_hpet_tsc(int *hpet, int *tsc)
 {
-	int tsc1, tsc2, hpet1;
+	int tsc1, tsc2, hpet1, i;
 
-	do {
+	for (i = 0; i < MAX_TRIES; i++) {
 		tsc1 = get_cycles_sync();
 		hpet1 = hpet_readl(HPET_COUNTER);
 		tsc2 = get_cycles_sync();
-	} while (tsc2 - tsc1 > TICK_MIN);
+		if (tsc2 - tsc1 > TICK_MIN)
+			break;
+	}
 	*hpet = hpet1;
 	*tsc = tsc2;
 }
#1 lore raw
Quoted 9 lines · On Saturday 14 April 2007 01:28:20 Ravikiran G Thirumalai wrote:

Provide a failsafe mechanism to avoid kernel spinning for ever at read_hpet_tsc during early kernel bootup.

This failsafe mechanism was introduced in 21-rc,
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=2f7a2a79c3ebb44f8b1b7d9b4fd3a650eb69e544

But looks like the hpet split from time.c lost the commit.

This patch reintroduces the failsafe mechanism

Added thanks

-Andi