diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2020-04-15 08:09:01 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2020-04-15 08:09:01 +0000 |
commit | 56b2f33cf9cab85199e614d912b89218437228ba (patch) | |
tree | 983b480f2078e294179596b82d5e188353476bff /sys/arch/powerpc | |
parent | 9a6d294e9d68e13f23c44e8e05695af4ec460baf (diff) |
Switch powerpc to MI mplock implementation.
Reduce differences with others architectures and make it possible to use
WITNESS on it.
Rename & keep the current recursive lock implementation as it is used by
the pmap.
Tested by Peter J. Philipp, otto@ and cwen@.
ok kettenis@
Diffstat (limited to 'sys/arch/powerpc')
-rw-r--r-- | sys/arch/powerpc/include/mplock.h | 20 | ||||
-rw-r--r-- | sys/arch/powerpc/powerpc/lock_machdep.c | 30 | ||||
-rw-r--r-- | sys/arch/powerpc/powerpc/pmap.c | 10 |
3 files changed, 31 insertions, 29 deletions
diff --git a/sys/arch/powerpc/include/mplock.h b/sys/arch/powerpc/include/mplock.h index a412a6c07a4..6ff628bf4bc 100644 --- a/sys/arch/powerpc/include/mplock.h +++ b/sys/arch/powerpc/include/mplock.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mplock.h,v 1.3 2017/12/04 09:51:03 mpi Exp $ */ +/* $OpenBSD: mplock.h,v 1.4 2020/04/15 08:09:00 mpi Exp $ */ /* * Copyright (c) 2004 Niklas Hallqvist. All rights reserved. @@ -27,25 +27,27 @@ #ifndef _POWERPC_MPLOCK_H_ #define _POWERPC_MPLOCK_H_ +#define __USE_MI_MPLOCK + /* * Really simple spinlock implementation with recursive capabilities. * Correctness is paramount, no fancyness allowed. */ -struct __mp_lock { +struct __ppc_lock { volatile struct cpu_info *mpl_cpu; volatile long mpl_count; }; #ifndef _LOCORE -void __mp_lock_init(struct __mp_lock *); -void __mp_lock(struct __mp_lock *); -void __mp_unlock(struct __mp_lock *); -int __mp_release_all(struct __mp_lock *); -int __mp_release_all_but_one(struct __mp_lock *); -void __mp_acquire_count(struct __mp_lock *, int); -int __mp_lock_held(struct __mp_lock *, struct cpu_info *); +void __ppc_lock_init(struct __ppc_lock *); +void __ppc_lock(struct __ppc_lock *); +void __ppc_unlock(struct __ppc_lock *); +int __ppc_release_all(struct __ppc_lock *); +int __ppc_release_all_but_one(struct __ppc_lock *); +void __ppc_acquire_count(struct __ppc_lock *, int); +int __ppc_lock_held(struct __ppc_lock *, struct cpu_info *); #endif diff --git a/sys/arch/powerpc/powerpc/lock_machdep.c b/sys/arch/powerpc/powerpc/lock_machdep.c index b9d2d1a9774..c7e865df1ba 100644 --- a/sys/arch/powerpc/powerpc/lock_machdep.c +++ b/sys/arch/powerpc/powerpc/lock_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lock_machdep.c,v 1.8 2020/03/05 09:28:31 claudio Exp $ */ +/* $OpenBSD: lock_machdep.c,v 1.9 2020/04/15 08:09:00 mpi Exp $ */ /* * Copyright (c) 2007 Artur Grabowski <art@openbsd.org> @@ -27,7 +27,7 @@ #include <ddb/db_output.h> void -__mp_lock_init(struct __mp_lock *lock) +__ppc_lock_init(struct __ppc_lock *lock) { lock->mpl_cpu = NULL; lock->mpl_count = 0; @@ -43,7 +43,7 @@ extern int __mp_lock_spinout; #endif static __inline void -__mp_lock_spin(struct __mp_lock *mpl) +__ppc_lock_spin(struct __ppc_lock *mpl) { #ifndef MP_LOCKDEBUG while (mpl->mpl_count != 0) @@ -55,14 +55,14 @@ __mp_lock_spin(struct __mp_lock *mpl) CPU_BUSY_CYCLE(); if (nticks == 0) { - db_printf("__mp_lock(%p): lock spun out\n", mpl); + db_printf("__ppc_lock(%p): lock spun out\n", mpl); db_enter(); } #endif } void -__mp_lock(struct __mp_lock *mpl) +__ppc_lock(struct __ppc_lock *mpl) { /* * Please notice that mpl_count gets incremented twice for the @@ -92,18 +92,18 @@ __mp_lock(struct __mp_lock *mpl) } ppc_intr_enable(s); - __mp_lock_spin(mpl); + __ppc_lock_spin(mpl); } } void -__mp_unlock(struct __mp_lock *mpl) +__ppc_unlock(struct __ppc_lock *mpl) { int s; #ifdef MP_LOCKDEBUG if (mpl->mpl_cpu != curcpu()) { - db_printf("__mp_unlock(%p): not held lock\n", mpl); + db_printf("__ppc_unlock(%p): not held lock\n", mpl); db_enter(); } #endif @@ -118,14 +118,14 @@ __mp_unlock(struct __mp_lock *mpl) } int -__mp_release_all(struct __mp_lock *mpl) +__ppc_release_all(struct __ppc_lock *mpl) { int rv = mpl->mpl_count - 1; int s; #ifdef MP_LOCKDEBUG if (mpl->mpl_cpu != curcpu()) { - db_printf("__mp_release_all(%p): not held lock\n", mpl); + db_printf("__ppc_release_all(%p): not held lock\n", mpl); db_enter(); } #endif @@ -140,13 +140,13 @@ __mp_release_all(struct __mp_lock *mpl) } int -__mp_release_all_but_one(struct __mp_lock *mpl) +__ppc_release_all_but_one(struct __ppc_lock *mpl) { int rv = mpl->mpl_count - 2; #ifdef MP_LOCKDEBUG if (mpl->mpl_cpu != curcpu()) { - db_printf("__mp_release_all_but_one(%p): not held lock\n", mpl); + db_printf("__ppc_release_all_but_one(%p): not held lock\n", mpl); db_enter(); } #endif @@ -157,14 +157,14 @@ __mp_release_all_but_one(struct __mp_lock *mpl) } void -__mp_acquire_count(struct __mp_lock *mpl, int count) +__ppc_acquire_count(struct __ppc_lock *mpl, int count) { while (count--) - __mp_lock(mpl); + __ppc_lock(mpl); } int -__mp_lock_held(struct __mp_lock *mpl, struct cpu_info *ci) +__ppc_lock_held(struct __ppc_lock *mpl, struct cpu_info *ci) { return mpl->mpl_cpu == ci; } diff --git a/sys/arch/powerpc/powerpc/pmap.c b/sys/arch/powerpc/powerpc/pmap.c index 98d05ecd8cf..2534bfdc7d6 100644 --- a/sys/arch/powerpc/powerpc/pmap.c +++ b/sys/arch/powerpc/powerpc/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.171 2019/09/05 03:08:55 deraadt Exp $ */ +/* $OpenBSD: pmap.c,v 1.172 2020/04/15 08:09:00 mpi Exp $ */ /* * Copyright (c) 2015 Martin Pieuchot @@ -185,19 +185,19 @@ int physmem; int physmaxaddr; #ifdef MULTIPROCESSOR -struct __mp_lock pmap_hash_lock; +struct __ppc_lock pmap_hash_lock; -#define PMAP_HASH_LOCK_INIT() __mp_lock_init(&pmap_hash_lock) +#define PMAP_HASH_LOCK_INIT() __ppc_lock_init(&pmap_hash_lock) #define PMAP_HASH_LOCK(s) \ do { \ s = ppc_intr_disable(); \ - __mp_lock(&pmap_hash_lock); \ + __ppc_lock(&pmap_hash_lock); \ } while (0) #define PMAP_HASH_UNLOCK(s) \ do { \ - __mp_unlock(&pmap_hash_lock); \ + __ppc_unlock(&pmap_hash_lock); \ ppc_intr_enable(s); \ } while (0) |