/* Read TSC and the reference counters. Take care of SMI disturbance  */
static u64 tsc_read_refs(u64 *p, int hpet)
/* 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;
}