Skip to contentSkip to conversation

-rt fix TSC calibration from PM Timer

PATCH In review Joachim Deguara 2 participants 2 messages May 21, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 -rt fix TSC calibration from PM Timer

The code to calibrate TSC frequency from the PM timer does not work on my laptop with the 2.6.21-rt5.

[    0.247815] time.c: Detected 62117.606 MHz processor.

The code looks to be copied from the calibration from HPET but unfortunately it reports frequency instead of period in femtoseconds as the HPET does. I also rearranged the math to make the femtoseconds and kHz clearer but it does loose a negligible amount of precision.

arch/x86_64/kernel/tsc.c +3 -3
Index: 2.6-rt/arch/x86_64/kernel/tsc.c
===================================================================
@@ -187,14 +187,14 @@ void __init tsc_calibrate(void)
 		return;
 	}
 
-	tsc2 = (tsc2 - tsc1) * 1000000000L;
+	tsc2 = tsc2 - tsc1;
 
 	if (hpet) {
 		hpet2 = (hpet2 - hpet1) & 0xFFFFFFFF;
-		tsc1 = (hpet2 * hpet_readl(HPET_PERIOD)) / 1000;
+		tsc1 = hpet2 * hpet_readl(HPET_PERIOD) / 1e12;
 	} else {
 		pm2 = (pm2 -pm1) & ACPI_PM_MASK;
-		tsc1 = (pm2 * PMTMR_TICKS_PER_SEC) / 1000;
+		tsc1 = (pm2 * 1e3) / PMTMR_TICKS_PER_SEC;
 	}
 
 	tsc_khz = tsc2 / tsc1;
#1 lore raw
Quoted 4 lines · Joachim Deguara

The code to calibrate TSC frequency from the PM timer does not work on my laptop with the 2.6.21-rt5.

[    0.247815] time.c: Detected 62117.606 MHz processor.

I know. The code was fixed in the x86_64-hrt queue, but never moved to -rt. The sync to -hrt is already in the -rt6 pipeline.

tglx