Beispiel #1
0
static void __init lapic_cal_handler(struct clock_event_device *dev)
{
    unsigned long long tsc = 0;
    long tapic = apic_read(APIC_TMCCT);
    unsigned long pm = acpi_pm_read_early();

    if (cpu_has_tsc)
        rdtscll(tsc);

    switch (lapic_cal_loops++) {
    case 0:
        lapic_cal_t1 = tapic;
        lapic_cal_tsc1 = tsc;
        lapic_cal_pm1 = pm;
        lapic_cal_j1 = jiffies;
        break;

    case LAPIC_CAL_LOOPS:
        lapic_cal_t2 = tapic;
        lapic_cal_tsc2 = tsc;
        if (pm < lapic_cal_pm1)
            pm += ACPI_PM_OVRRUN;
        lapic_cal_pm2 = pm;
        lapic_cal_j2 = jiffies;
        break;
    }
}
Beispiel #2
0
/*
 * Read TSC and the reference counters. Take care of SMI disturbance
 */
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)
			*p = hpet_readl(HPET_COUNTER) & 0xFFFFFFFF;
		else
			*p = acpi_pm_read_early();
		t2 = get_cycles();
		if ((t2 - t1) < SMI_TRESHOLD)
			return t2;
	}
	return ULLONG_MAX;
}