For the amd64 platform, we can depend on the TSC being present. This patch
changes DELAY to use the TSC once it has been calibrated. This does NOT use the TSC for long-term timekeeping. It only uses it to bound the DELAY() spinloop. This should not be affected by the Athlon64 X2 TSC quirks because the cpu is not halted while we use DELAY().
This commit is contained in:
parent
fbd68c4b4c
commit
6bcdd71391
@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/limits.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/sched.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/cons.h>
|
||||
#include <sys/power.h>
|
||||
@ -269,7 +270,21 @@ DELAY(int n)
|
||||
int getit_calls = 1;
|
||||
int n1;
|
||||
static int state = 0;
|
||||
#endif
|
||||
|
||||
if (tsc_freq != 0 && !tsc_is_broken) {
|
||||
uint64_t start, end, now;
|
||||
|
||||
sched_pin();
|
||||
start = rdtsc();
|
||||
end = start + (tsc_freq * n) / 1000000;
|
||||
do {
|
||||
now = rdtsc();
|
||||
} while (now < end || (now > start && end < start));
|
||||
sched_unpin();
|
||||
return;
|
||||
}
|
||||
#ifdef DELAYDEBUG
|
||||
if (state == 0) {
|
||||
state = 1;
|
||||
for (n1 = 1; n1 <= 10000000; n1 *= 10)
|
||||
|
Loading…
x
Reference in New Issue
Block a user