Skip to content

Commit

Permalink
x86: TSC: use one set of reference variables
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Thomas Gleixner authored and Ingo Molnar committed Sep 4, 2008
1 parent d683ef7 commit 827014b
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions arch/x86/kernel/tsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ __setup("notsc", notsc_setup);
/*
* Read TSC and the reference counters. Take care of SMI disturbance
*/
static u64 tsc_read_refs(u64 *pm, u64 *hpet)
static u64 tsc_read_refs(u64 *p, int hpet)
{
u64 t1, t2;
int i;

for (i = 0; i < MAX_RETRIES; i++) {
t1 = get_cycles();
if (hpet)
*hpet = hpet_readl(HPET_COUNTER) & 0xFFFFFFFF;
*p = hpet_readl(HPET_COUNTER) & 0xFFFFFFFF;
else
*pm = acpi_pm_read_early();
*p = acpi_pm_read_early();
t2 = get_cycles();
if ((t2 - t1) < SMI_TRESHOLD)
return t2;
Expand Down Expand Up @@ -228,7 +228,7 @@ static unsigned long pit_calibrate_tsc(void)
*/
unsigned long native_calibrate_tsc(void)
{
u64 tsc1, tsc2, delta, pm1, pm2, hpet1, hpet2;
u64 tsc1, tsc2, delta, ref1, ref2;
unsigned long tsc_pit_min = ULONG_MAX, tsc_ref_min = ULONG_MAX;
unsigned long flags;
int hpet = is_hpet_enabled(), i;
Expand Down Expand Up @@ -267,16 +267,16 @@ unsigned long native_calibrate_tsc(void)
* read the end value.
*/
local_irq_save(flags);
tsc1 = tsc_read_refs(&pm1, hpet ? &hpet1 : NULL);
tsc1 = tsc_read_refs(&ref1, hpet);
tsc_pit_khz = pit_calibrate_tsc();
tsc2 = tsc_read_refs(&pm2, hpet ? &hpet2 : NULL);
tsc2 = tsc_read_refs(&ref2, hpet);
local_irq_restore(flags);

/* Pick the lowest PIT TSC calibration so far */
tsc_pit_min = min(tsc_pit_min, tsc_pit_khz);

/* hpet or pmtimer available ? */
if (!hpet && !pm1 && !pm2)
if (!hpet && !ref1 && !ref2)
continue;

/* Check, whether the sampling was disturbed by an SMI */
Expand All @@ -285,9 +285,9 @@ unsigned long native_calibrate_tsc(void)

tsc2 = (tsc2 - tsc1) * 1000000LL;
if (hpet)
tsc2 = calc_hpet_ref(tsc2, hpet1, hpet2);
tsc2 = calc_hpet_ref(tsc2, ref1, ref2);
else
tsc2 = calc_pmtimer_ref(tsc2, pm1, pm2);
tsc2 = calc_pmtimer_ref(tsc2, ref1, ref2);

tsc_ref_min = min(tsc_ref_min, (unsigned long) tsc2);
}
Expand All @@ -301,7 +301,7 @@ unsigned long native_calibrate_tsc(void)
"SMI disturbance.\n");

/* We don't have an alternative source, disable TSC */
if (!hpet && !pm1 && !pm2) {
if (!hpet && !ref1 && !ref2) {
printk("TSC: No reference (HPET/PMTIMER) available\n");
return 0;
}
Expand All @@ -321,7 +321,7 @@ unsigned long native_calibrate_tsc(void)
}

/* We don't have an alternative source, use the PIT calibration value */
if (!hpet && !pm1 && !pm2) {
if (!hpet && !ref1 && !ref2) {
printk(KERN_INFO "TSC: Using PIT calibration value\n");
return tsc_pit_min;
}
Expand Down

0 comments on commit 827014b

Please sign in to comment.