summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2015-09-21 06:21:50 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2015-09-21 06:21:50 +0000
commita7cfa4c53e7a3674129abbdeeffb602d734925da (patch)
treeeb77ea09aa47ded8ff38d06e258eb07da8745df7 /sys/arch
parent4286a8bf94a6498e04746ef87ad939d2d85ab4da (diff)
Fix membar positioning in mtx_enter_try() and (critically!) mtx_leave()
Same diff as guenther@ committed for alpha. ok guenther@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/powerpc/powerpc/mutex.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/arch/powerpc/powerpc/mutex.c b/sys/arch/powerpc/powerpc/mutex.c
index dd89ae0747f..2e51bba22c7 100644
--- a/sys/arch/powerpc/powerpc/mutex.c
+++ b/sys/arch/powerpc/powerpc/mutex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mutex.c,v 1.1 2015/08/14 06:14:19 dlg Exp $ */
+/* $OpenBSD: mutex.c,v 1.2 2015/09/21 06:21:49 kettenis Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
@@ -87,12 +87,12 @@ mtx_enter_try(struct mutex *mtx)
panic("mtx %p: locking against myself", mtx);
#endif
if (owner == NULL) {
+ membar_enter();
if (mtx->mtx_wantipl != IPL_NONE)
mtx->mtx_oldipl = s;
#ifdef DIAGNOSTIC
ci->ci_mutex_level++;
#endif
- membar_enter();
return (1);
}
@@ -136,14 +136,14 @@ mtx_leave(struct mutex *mtx)
MUTEX_ASSERT_LOCKED(mtx);
-#ifdef MULTIPROCESSOR
- membar_exit();
-#endif
#ifdef DIAGNOSTIC
curcpu()->ci_mutex_level--;
#endif
s = mtx->mtx_oldipl;
+#ifdef MULTIPROCESSOR
+ membar_exit();
+#endif
mtx->mtx_owner = NULL;
if (mtx->mtx_wantipl != IPL_NONE)
splx(s);