diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2010-05-17 11:25:09 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2010-05-17 11:25:09 +0000 |
commit | 04609821251a7e6d8d0e0bac3c585ef5574bc14d (patch) | |
tree | aeea90999cf0ac14e0e62c1022d83da064edbfc0 /sys/arch | |
parent | e5544059c2e1bdfcaee46ea071b92af734b115d0 (diff) |
Fix locking logic, remembering that hppa locks are inverted. Whilst here
also add mpl_cpu and curcpu() to the debugging messages.
Issue spotted by and ok kettenis@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/hppa/hppa/lock_machdep.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/sys/arch/hppa/hppa/lock_machdep.c b/sys/arch/hppa/hppa/lock_machdep.c index 1480ae45f6d..00377d39667 100644 --- a/sys/arch/hppa/hppa/lock_machdep.c +++ b/sys/arch/hppa/hppa/lock_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lock_machdep.c,v 1.1 2010/03/25 14:26:21 jsing Exp $ */ +/* $OpenBSD: lock_machdep.c,v 1.2 2010/05/17 11:25:08 jsing Exp $ */ /* * Copyright (c) 2007 Artur Grabowski <art@openbsd.org> @@ -32,17 +32,17 @@ __cpu_cas(struct __mp_lock *mpl, volatile unsigned long *addr, unsigned long old, unsigned long new) { volatile int *lock = (int *)(((vaddr_t)mpl->mpl_lock + 0xf) & ~0xf); - volatile register_t locked = 0; + volatile register_t old_lock = 0; int ret = 1; /* Note: lock must be 16-byte aligned. */ asm volatile ( "ldcws 0(%2), %0" - : "=&r" (locked), "+m" (lock) + : "=&r" (old_lock), "+m" (lock) : "r" (lock) ); - if (locked == MPL_LOCKED) { + if (old_lock == MPL_UNLOCKED) { if (*addr == old) { *addr = new; asm("sync" ::: "memory"); @@ -136,7 +136,8 @@ __mp_unlock(struct __mp_lock *mpl) #ifdef MP_LOCKDEBUG if (mpl->mpl_cpu != curcpu()) { - db_printf("__mp_unlock(%p): not held lock\n", mpl); + db_printf("__mp_unlock(%p): lock not held - %p != %p\n", + mpl, mpl->mpl_cpu, curcpu()); Debugger(); } #endif @@ -158,7 +159,8 @@ __mp_release_all(struct __mp_lock *mpl) #ifdef MP_LOCKDEBUG if (mpl->mpl_cpu != curcpu()) { - db_printf("__mp_release_all(%p): not held lock\n", mpl); + db_printf("__mp_release_all(%p): lock not held - %p != %p\n", + mpl, mpl->mpl_cpu, curcpu()); Debugger(); } #endif @@ -179,7 +181,8 @@ __mp_release_all_but_one(struct __mp_lock *mpl) #ifdef MP_LOCKDEBUG if (mpl->mpl_cpu != curcpu()) { - db_printf("__mp_release_all_but_one(%p): not held lock\n", mpl); + db_printf("__mp_release_all_but_one(%p): lock not held - " + "%p != %p\n", mpl, mpl->mpl_cpu, curcpu()); Debugger(); } #endif |