diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2009-02-18 21:09:02 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2009-02-18 21:09:02 +0000 |
commit | da8a9fe09342881e691db6ec87d6f0aa33c59f98 (patch) | |
tree | 5ee5632004fb2a48ac8966e2cede1425f7fbb6a0 /sys | |
parent | 538f394b4f87b368ab4e98f555e911340f397872 (diff) |
In __cpu_simple_lock(), do not hog the bus with exclusive accesses; if
xmem didn't return the expected value, spin doing regular loads until it
appears we have a chance to grab the lock again.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/m88k/include/lock.h | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/sys/arch/m88k/include/lock.h b/sys/arch/m88k/include/lock.h index 06eebcfaf2d..a6f3f13061a 100644 --- a/sys/arch/m88k/include/lock.h +++ b/sys/arch/m88k/include/lock.h @@ -1,6 +1,6 @@ #ifndef _M88K_LOCK_H_ #define _M88K_LOCK_H_ -/* $OpenBSD: lock.h,v 1.6 2007/12/02 21:21:29 miod Exp $ */ +/* $OpenBSD: lock.h,v 1.7 2009/02/18 21:09:01 miod Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat. @@ -41,24 +41,6 @@ __cpu_simple_lock_init(__cpu_simple_lock_t *l) *l = __SIMPLELOCK_UNLOCKED; } -static __inline__ void -__cpu_simple_lock(__cpu_simple_lock_t *l) -{ - /* - * The local __cpu_simple_lock_t is not declared volatile, so that - * stores to it can be optimized away, since we will use a register - * and only spin on it. xmem will do the right thing regardless of - * the volatile qualifier. - */ - u_int old; - - do { - old = __SIMPLELOCK_LOCKED; - __asm__ __volatile__ - ("xmem %0, %2, r0" : "+r"(old), "+m"(*l) : "r"(l)); - } while (old != __SIMPLELOCK_UNLOCKED); -} - static __inline__ int __cpu_simple_lock_try(__cpu_simple_lock_t *l) { @@ -76,6 +58,17 @@ __cpu_simple_lock_try(__cpu_simple_lock_t *l) } static __inline__ void +__cpu_simple_lock(__cpu_simple_lock_t *l) +{ + for (;;) { + if (__cpu_simple_lock_try(l) != 0) + break; + while (*l != __SIMPLELOCK_UNLOCKED) + ; /* spin without exclusive bus access */ + } +} + +static __inline__ void __cpu_simple_unlock(__cpu_simple_lock_t *l) { *l = __SIMPLELOCK_UNLOCKED; |