diff options
author | John Baldwin <jhb@FreeBSD.org> | 2018-11-05 22:54:03 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2018-11-05 22:54:03 +0000 |
commit | 7f7f6f85a1314f9fe9ad238863dbf1e77d3ecf06 (patch) | |
tree | 1ed7e7db92b7abca4a27eb55d5ad1766f8de7f51 /sys/x86 | |
parent | c35530f46401198a25e194a3d618752b098cc866 (diff) | |
download | src-7f7f6f85a1314f9fe9ad238863dbf1e77d3ecf06.tar.gz src-7f7f6f85a1314f9fe9ad238863dbf1e77d3ecf06.zip |
Add a custom implementation of cpu_lock_delay() for x86.
Avoid using DELAY() since it can try to use spin locks on CPUs without
a P-state invariant TSC. For cpu_lock_delay(), always use the TSC if
it exists (even if it is not P-state invariant) to delay for a
microsecond. If the TSC does not exist, read from I/O port 0x84 to
delay instead.
PR: 228768
Reported by: Roger Hammerstein <cheeky.m@live.com>
Reviewed by: kib
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D17851
Notes
Notes:
svn path=/head/; revision=340170
Diffstat (limited to 'sys/x86')
-rw-r--r-- | sys/x86/x86/delay.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/x86/x86/delay.c b/sys/x86/x86/delay.c index 230902ddaa10..c767250954da 100644 --- a/sys/x86/x86/delay.c +++ b/sys/x86/x86/delay.c @@ -122,3 +122,22 @@ DELAY(int n) init_ops.early_delay(n); TSEXIT(); } + +void +cpu_lock_delay(void) +{ + + /* + * Use TSC to wait for a usec if present, otherwise fall back + * to reading from port 0x84. We can't call into timecounters + * for this delay since timecounters might use spin locks. + * + * Note that unlike delay_tc(), this uses the TSC even if it + * is not P-state invariant. For this function it is ok to + * wait even a few usecs. + */ + if (tsc_freq != 0) + delay_tsc(1); + else + inb(0x84); +} |