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

I forgot to initialize cpu_khz in the ACPI PM timesource init code.



 25-akpm/arch/i386/kernel/timers/common.c        |   20 ++++++++++++++++++++
 25-akpm/arch/i386/kernel/timers/timer_cyclone.c |   21 +--------------------
 25-akpm/arch/i386/kernel/timers/timer_pm.c      |    8 ++++++--
 25-akpm/arch/i386/kernel/timers/timer_tsc.c     |    2 +-
 25-akpm/include/asm-i386/timer.h                |    1 +
 5 files changed, 29 insertions(+), 23 deletions(-)

diff -puN arch/i386/kernel/timers/common.c~acpi-pm_timer-init-cpu_khz arch/i386/kernel/timers/common.c
--- 25/arch/i386/kernel/timers/common.c~acpi-pm_timer-init-cpu_khz	Mon Nov 17 15:17:47 2003
+++ 25-akpm/arch/i386/kernel/timers/common.c	Mon Nov 17 15:17:47 2003
@@ -137,3 +137,23 @@ bad_calibration:
 }
 #endif
 
+/* calculate cpu_khz */
+void __init init_cpu_khz(void)
+{
+	if (cpu_has_tsc) {
+		unsigned long tsc_quotient = calibrate_tsc();
+		if (tsc_quotient) {
+			/* report CPU clock rate in Hz.
+			 * The formula is (10^6 * 2^32) / (2^32 * 1 / (clocks/us)) =
+			 * clock/second. Our precision is about 100 ppm.
+			 */
+			{	unsigned long eax=0, edx=1000;
+				__asm__("divl %2"
+		       		:"=a" (cpu_khz), "=d" (edx)
+        	       		:"r" (tsc_quotient),
+	                	"0" (eax), "1" (edx));
+				printk("Detected %lu.%03lu MHz processor.\n", cpu_khz / 1000, cpu_khz % 1000);
+			}
+		}
+	}
+}
diff -puN arch/i386/kernel/timers/timer_cyclone.c~acpi-pm_timer-init-cpu_khz arch/i386/kernel/timers/timer_cyclone.c
--- 25/arch/i386/kernel/timers/timer_cyclone.c~acpi-pm_timer-init-cpu_khz	Mon Nov 17 15:17:47 2003
+++ 25-akpm/arch/i386/kernel/timers/timer_cyclone.c	Mon Nov 17 15:17:47 2003
@@ -212,26 +212,7 @@ static int __init init_cyclone(char* ove
 		}
 	}
 
-	/* init cpu_khz.
-	 * XXX - This should really be done elsewhere, 
-	 * 		and in a more generic fashion. -johnstul@us.ibm.com
-	 */
-	if (cpu_has_tsc) {
-		unsigned long tsc_quotient = calibrate_tsc();
-		if (tsc_quotient) {
-			/* report CPU clock rate in Hz.
-			 * The formula is (10^6 * 2^32) / (2^32 * 1 / (clocks/us)) =
-			 * clock/second. Our precision is about 100 ppm.
-			 */
-			{	unsigned long eax=0, edx=1000;
-				__asm__("divl %2"
-		       		:"=a" (cpu_khz), "=d" (edx)
-        	       		:"r" (tsc_quotient),
-	                	"0" (eax), "1" (edx));
-				printk("Detected %lu.%03lu MHz processor.\n", cpu_khz / 1000, cpu_khz % 1000);
-			}
-		}
-	}
+	init_cpu_khz();
 
 	/* Everything looks good! */
 	return 0;
diff -puN arch/i386/kernel/timers/timer_pm.c~acpi-pm_timer-init-cpu_khz arch/i386/kernel/timers/timer_pm.c
--- 25/arch/i386/kernel/timers/timer_pm.c~acpi-pm_timer-init-cpu_khz	Mon Nov 17 15:17:47 2003
+++ 25-akpm/arch/i386/kernel/timers/timer_pm.c	Mon Nov 17 15:17:47 2003
@@ -57,14 +57,18 @@ static int init_pmtmr(char* override)
 		if (value2 == value1)
 			continue;
 		if (value2 > value1)
-			return 0;
+			goto pm_good;
 		if ((value2 < value1) && ((value2) < 0xFFF))
-			return 0;
+			goto pm_good;
 		printk(KERN_INFO "PM-Timer had inconsistent results: 0x%#x, 0x%#x - aborting.\n", value1, value2);
 		return -EINVAL;
 	}
 	printk(KERN_INFO "PM-Timer had no reasonable result: 0x%#x - aborting.\n", value1);
 	return -ENODEV;
+
+pm_good:
+	init_cpu_khz();
+	return 0;
 }
 
 static inline u32 cyc2us(u32 cycles)
diff -puN include/asm-i386/timer.h~acpi-pm_timer-init-cpu_khz include/asm-i386/timer.h
--- 25/include/asm-i386/timer.h~acpi-pm_timer-init-cpu_khz	Mon Nov 17 15:17:47 2003
+++ 25-akpm/include/asm-i386/timer.h	Mon Nov 17 15:17:47 2003
@@ -40,6 +40,7 @@ extern struct timer_opts timer_cyclone;
 #endif
 
 extern unsigned long calibrate_tsc(void);
+extern void init_cpu_khz(void);
 #ifdef CONFIG_HPET_TIMER
 extern struct timer_opts timer_hpet;
 extern unsigned long calibrate_tsc_hpet(unsigned long *tsc_hpet_quotient_ptr);