Date: Tue, 29 Nov 2005 00:49:27 GMT From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 87400 for review Message-ID: <200511290049.jAT0nRDO041051@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=87400 Change 87400 by peter@peter_daintree on 2005/11/29 00:48:28 add a knob to use the TSC to implement the DELAY() spin loop. Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/tsc.c#12 edit .. //depot/projects/hammer/sys/amd64/include/clock.h#17 edit .. //depot/projects/hammer/sys/amd64/isa/clock.c#49 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/tsc.c#12 (text+ko) ==== @@ -128,3 +128,15 @@ { return (rdtsc()); } + +void +tsc_DELAY(int n) +{ + uint64_t start, end, now; + + start = rdtsc(); + end = start + (tsc_freq * n) / 1000000; + do { + now = rdtsc(); + } while (now < end || (now > start && end < start)); +} ==== //depot/projects/hammer/sys/amd64/include/clock.h#17 (text+ko) ==== @@ -37,6 +37,7 @@ int sysbeep(int pitch, int period); void init_TSC(void); void init_TSC_tc(void); +void tsc_DELAY(int); #endif /* _KERNEL */ ==== //depot/projects/hammer/sys/amd64/isa/clock.c#49 (text+ko) ==== @@ -255,6 +255,9 @@ return ((high << 8) | low); } +static int do_tsc_delay = 0; +SYSCTL_INT(_debug, OID_AUTO, do_tsc_delay, CTLFLAG_RW, &do_tsc_delay, 0, + "use TSC for DELAY()"); /* * Wait "n" microseconds. * Relies on timer 1 counting down from (timer_freq / hz) @@ -269,7 +272,13 @@ int getit_calls = 1; int n1; static int state = 0; +#endif + if (tsc_freq != 0 && !tsc_is_broken) { + tsc_DELAY(n); + return; + } +#ifdef DELAYDEBUG if (state == 0) { state = 1; for (n1 = 1; n1 <= 10000000; n1 *= 10)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200511290049.jAT0nRDO041051>