Fix final bugs in memory barriers on PowerPC:

- Use isync/lwsync unconditionally for acquire/release. Use of isync
  guarantees a complete memory barrier, which is important for serialization
  of bus space accesses with mutexes on multi-processor systems.
- Go back to using sync as the I/O memory barrier, which solves the same
  problem as above with respect to mutex release using lwsync, while not
  penalizing non-I/O operations like a return to sync on the atomic release
  operations would.
- Place an acquisition barrier around thread lock acquisition in
  cpu_switchin().
This commit is contained in:
Nathan Whitehorn 2012-05-04 16:00:22 +00:00
parent 88d935dad7
commit bc96dccc69
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=235013
4 changed files with 10 additions and 8 deletions

View File

@ -124,7 +124,8 @@ cpu_switchin:
blocked_loop:
lwz %r7,TD_LOCK(%r2)
cmpw %r6,%r7
beq blocked_loop
beq- blocked_loop
isync
#endif
mfsprg %r7,0 /* Get the pcpu pointer */

View File

@ -150,7 +150,8 @@ cpu_switchin:
blocked_loop:
ld %r7,TD_LOCK(%r13)
cmpd %r6,%r7
beq blocked_loop
beq- blocked_loop
isync
#endif
mfsprg %r7,0 /* Get the pcpu pointer */

View File

@ -51,13 +51,8 @@
* with the atomic lXarx/stXcx. sequences below. See Appendix B.2 of Book II
* of the architecture manual.
*/
#ifdef __powerpc64__
#define __ATOMIC_REL() __asm __volatile("lwsync" : : : "memory")
#define __ATOMIC_ACQ() __asm __volatile("lwsync" : : : "memory")
#else
#define __ATOMIC_REL() __asm __volatile("lwsync" : : : "memory")
#define __ATOMIC_ACQ() __asm __volatile("isync" : : : "memory")
#endif
/*
* atomic_add(p, v)

View File

@ -39,7 +39,12 @@
* I/O macros.
*/
#define powerpc_iomb() __asm __volatile("eieio" : : : "memory")
/*
* Use sync so that bus space operations cannot sneak out the bottom of
* mutex-protected sections (mutex release does not guarantee completion of
* accesses to caching-inhibited memory on some systems)
*/
#define powerpc_iomb() __asm __volatile("sync" : : : "memory")
static __inline void
__outb(volatile u_int8_t *a, u_int8_t v)