summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2014-06-17 15:43:28 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2014-06-17 15:43:28 +0000
commit740eda0f4ef9c2dbb3fe6341b32e00df804637a2 (patch)
tree16c65b0eb0f71d90fc0ad7b0bbedd72a358dd41d /sys/arch
parente2af69cba3ebd0ac988f7db6c81d31a76188babd (diff)
Add membars to guarantee mtx_oldipl is written after locking and
read before unlocking. Believed to fix some spl problems on MP that have had landry and tobaisu seeing red. suggestion to use membar API from matthew@ ok matthew@ kettenis@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/hppa/hppa/mutex.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/arch/hppa/hppa/mutex.c b/sys/arch/hppa/hppa/mutex.c
index 25cb4b371be..ab1df14070e 100644
--- a/sys/arch/hppa/hppa/mutex.c
+++ b/sys/arch/hppa/hppa/mutex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mutex.c,v 1.12 2014/01/30 15:18:51 kettenis Exp $ */
+/* $OpenBSD: mutex.c,v 1.13 2014/06/17 15:43:27 guenther Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
@@ -28,6 +28,7 @@
#include <sys/param.h>
#include <sys/mutex.h>
#include <sys/systm.h>
+#include <sys/atomic.h>
#include <machine/intr.h>
@@ -69,6 +70,7 @@ mtx_enter(struct mutex *mtx)
if (mtx->mtx_wantipl != IPL_NONE)
s = splraise(mtx->mtx_wantipl);
if (try_lock(mtx)) {
+ membar_enter();
if (mtx->mtx_wantipl != IPL_NONE)
mtx->mtx_oldipl = s;
mtx->mtx_owner = curcpu();
@@ -90,6 +92,7 @@ mtx_enter_try(struct mutex *mtx)
if (mtx->mtx_wantipl != IPL_NONE)
s = splraise(mtx->mtx_wantipl);
if (try_lock(mtx)) {
+ membar_enter();
if (mtx->mtx_wantipl != IPL_NONE)
mtx->mtx_oldipl = s;
mtx->mtx_owner = curcpu();
@@ -116,6 +119,7 @@ mtx_leave(struct mutex *mtx)
#endif
s = mtx->mtx_oldipl;
mtx->mtx_owner = NULL;
+ membar_exit();
mtx->mtx_lock[0] = 1;
mtx->mtx_lock[1] = 1;