Lower the bar for ACPI-fast on real machines slightly. Empirical evidences

show that there are perfectly working PM timers with occasional "hiccups",
probably because of an SMI.  Now we ignore the maximum if it happens once in
the test loop and the width is small enough.  Also, relax normal width a bit
to count in a boundary case.
This commit is contained in:
Jung-uk Kim 2011-04-05 18:40:19 +00:00
parent f5459d4cad
commit 9abd8cd05b

View File

@ -306,12 +306,12 @@ SYSCTL_PROC(_machdep, OID_AUTO, acpi_timer_freq, CTLTYPE_INT | CTLFLAG_RW,
static int
acpi_timer_test()
{
uint32_t last, this;
int min, max, n, delta;
register_t s;
uint32_t last, this;
int delta, max, max2, min, n;
register_t s;
min = INT32_MAX;
max = 0;
max = max2 = 0;
/* Test the timer with interrupts disabled to get accurate results. */
s = intr_disable();
@ -319,18 +319,21 @@ acpi_timer_test()
for (n = 0; n < N; n++) {
this = acpi_timer_read();
delta = acpi_TimerDelta(this, last);
if (delta > max)
if (delta > max) {
max2 = max;
max = delta;
} else if (delta > max2)
max2 = delta;
if (delta < min)
min = delta;
last = this;
}
intr_restore(s);
delta = max - min;
if (delta > 2 && vm_guest == VM_GUEST_NO)
delta = max2 - min;
if ((max - min > 8 || delta > 3) && vm_guest == VM_GUEST_NO)
n = 0;
else if (min < 0 || max == 0)
else if (min < 0 || max == 0 || max2 == 0)
n = 0;
else
n = 1;