aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/tsc.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2008-09-04 11:18:53 -0400
committerIngo Molnar <mingo@elte.hu>2008-09-04 11:35:34 -0400
commit827014be05e4515fa0dfc32e3100c4dab2070a98 (patch)
tree18fbc2c4cd6866d2fac25ad7ba74b89884879e87 /arch/x86/kernel/tsc.c
parentd683ef7afe8b6dbac6a3c681cef8a908357793ca (diff)
x86: TSC: use one set of reference variables
Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/tsc.c')
-rw-r--r--arch/x86/kernel/tsc.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index ebb9bf824a0..52284d31fc9 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -104,7 +104,7 @@ __setup("notsc", notsc_setup);
104/* 104/*
105 * Read TSC and the reference counters. Take care of SMI disturbance 105 * Read TSC and the reference counters. Take care of SMI disturbance
106 */ 106 */
107static u64 tsc_read_refs(u64 *pm, u64 *hpet) 107static u64 tsc_read_refs(u64 *p, int hpet)
108{ 108{
109 u64 t1, t2; 109 u64 t1, t2;
110 int i; 110 int i;
@@ -112,9 +112,9 @@ static u64 tsc_read_refs(u64 *pm, u64 *hpet)
112 for (i = 0; i < MAX_RETRIES; i++) { 112 for (i = 0; i < MAX_RETRIES; i++) {
113 t1 = get_cycles(); 113 t1 = get_cycles();
114 if (hpet) 114 if (hpet)
115 *hpet = hpet_readl(HPET_COUNTER) & 0xFFFFFFFF; 115 *p = hpet_readl(HPET_COUNTER) & 0xFFFFFFFF;
116 else 116 else
117 *pm = acpi_pm_read_early(); 117 *p = acpi_pm_read_early();
118 t2 = get_cycles(); 118 t2 = get_cycles();
119 if ((t2 - t1) < SMI_TRESHOLD) 119 if ((t2 - t1) < SMI_TRESHOLD)
120 return t2; 120 return t2;
@@ -228,7 +228,7 @@ static unsigned long pit_calibrate_tsc(void)
228 */ 228 */
229unsigned long native_calibrate_tsc(void) 229unsigned long native_calibrate_tsc(void)
230{ 230{
231 u64 tsc1, tsc2, delta, pm1, pm2, hpet1, hpet2; 231 u64 tsc1, tsc2, delta, ref1, ref2;
232 unsigned long tsc_pit_min = ULONG_MAX, tsc_ref_min = ULONG_MAX; 232 unsigned long tsc_pit_min = ULONG_MAX, tsc_ref_min = ULONG_MAX;
233 unsigned long flags; 233 unsigned long flags;
234 int hpet = is_hpet_enabled(), i; 234 int hpet = is_hpet_enabled(), i;
@@ -267,16 +267,16 @@ unsigned long native_calibrate_tsc(void)
267 * read the end value. 267 * read the end value.
268 */ 268 */
269 local_irq_save(flags); 269 local_irq_save(flags);
270 tsc1 = tsc_read_refs(&pm1, hpet ? &hpet1 : NULL); 270 tsc1 = tsc_read_refs(&ref1, hpet);
271 tsc_pit_khz = pit_calibrate_tsc(); 271 tsc_pit_khz = pit_calibrate_tsc();
272 tsc2 = tsc_read_refs(&pm2, hpet ? &hpet2 : NULL); 272 tsc2 = tsc_read_refs(&ref2, hpet);
273 local_irq_restore(flags); 273 local_irq_restore(flags);
274 274
275 /* Pick the lowest PIT TSC calibration so far */ 275 /* Pick the lowest PIT TSC calibration so far */
276 tsc_pit_min = min(tsc_pit_min, tsc_pit_khz); 276 tsc_pit_min = min(tsc_pit_min, tsc_pit_khz);
277 277
278 /* hpet or pmtimer available ? */ 278 /* hpet or pmtimer available ? */
279 if (!hpet && !pm1 && !pm2) 279 if (!hpet && !ref1 && !ref2)
280 continue; 280 continue;
281 281
282 /* Check, whether the sampling was disturbed by an SMI */ 282 /* Check, whether the sampling was disturbed by an SMI */
@@ -285,9 +285,9 @@ unsigned long native_calibrate_tsc(void)
285 285
286 tsc2 = (tsc2 - tsc1) * 1000000LL; 286 tsc2 = (tsc2 - tsc1) * 1000000LL;
287 if (hpet) 287 if (hpet)
288 tsc2 = calc_hpet_ref(tsc2, hpet1, hpet2); 288 tsc2 = calc_hpet_ref(tsc2, ref1, ref2);
289 else 289 else
290 tsc2 = calc_pmtimer_ref(tsc2, pm1, pm2); 290 tsc2 = calc_pmtimer_ref(tsc2, ref1, ref2);
291 291
292 tsc_ref_min = min(tsc_ref_min, (unsigned long) tsc2); 292 tsc_ref_min = min(tsc_ref_min, (unsigned long) tsc2);
293 } 293 }
@@ -301,7 +301,7 @@ unsigned long native_calibrate_tsc(void)
301 "SMI disturbance.\n"); 301 "SMI disturbance.\n");
302 302
303 /* We don't have an alternative source, disable TSC */ 303 /* We don't have an alternative source, disable TSC */
304 if (!hpet && !pm1 && !pm2) { 304 if (!hpet && !ref1 && !ref2) {
305 printk("TSC: No reference (HPET/PMTIMER) available\n"); 305 printk("TSC: No reference (HPET/PMTIMER) available\n");
306 return 0; 306 return 0;
307 } 307 }
@@ -321,7 +321,7 @@ unsigned long native_calibrate_tsc(void)
321 } 321 }
322 322
323 /* We don't have an alternative source, use the PIT calibration value */ 323 /* We don't have an alternative source, use the PIT calibration value */
324 if (!hpet && !pm1 && !pm2) { 324 if (!hpet && !ref1 && !ref2) {
325 printk(KERN_INFO "TSC: Using PIT calibration value\n"); 325 printk(KERN_INFO "TSC: Using PIT calibration value\n");
326 return tsc_pit_min; 326 return tsc_pit_min;
327 } 327 }