summaryrefslogtreecommitdiff
path: root/sys/arch/arm
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2013-05-09 14:27:18 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2013-05-09 14:27:18 +0000
commitd9ef2c9913f8d2ebc7ea261cccfacd64f4c46c23 (patch)
tree363ccb0ada8b3efc83442418d45fe9c9cecc46ac /sys/arch/arm
parente9f73402fc1273bc7e73164ff6e3106983f2549a (diff)
Implement mtx_enter_try for armv7 and handle ci_mutex_level.
From drahn and oga at bitrig. ok bmercer@
Diffstat (limited to 'sys/arch/arm')
-rw-r--r--sys/arch/arm/armv7/armv7_mutex.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/sys/arch/arm/armv7/armv7_mutex.c b/sys/arch/arm/armv7/armv7_mutex.c
index bc8b37693d7..47120723594 100644
--- a/sys/arch/arm/armv7/armv7_mutex.c
+++ b/sys/arch/arm/armv7/armv7_mutex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: armv7_mutex.c,v 1.1 2009/05/08 02:57:32 drahn Exp $ */
+/* $OpenBSD: armv7_mutex.c,v 1.2 2013/05/09 14:27:17 patrick Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
@@ -58,6 +58,27 @@ mtx_enter(struct mutex *mtx)
MUTEX_ASSERT_UNLOCKED(mtx);
mtx->mtx_lock = 1;
+#ifdef DIAGNOSTIC
+ curcpu()->ci_mutex_level++;
+#endif
+}
+
+int
+mtx_enter_try(struct mutex *mtx)
+{
+ if (mtx->mtx_wantipl != IPL_NONE)
+ mtx->mtx_oldipl = _splraise(mtx->mtx_wantipl);
+
+ if (mtx->mtx_lock) {
+ splx(mtx->mtx_oldipl);
+ return 0;
+ }
+ mtx->mtx_lock = 1;
+#ifdef DIAGNOSTIC
+ curcpu()->ci_mutex_level++;
+#endif
+
+ return 1;
}
void
@@ -65,6 +86,9 @@ mtx_leave(struct mutex *mtx)
{
MUTEX_ASSERT_LOCKED(mtx);
mtx->mtx_lock = 0;
+#ifdef DIAGNOSTIC
+ curcpu()->ci_mutex_level--;
+#endif
if (mtx->mtx_wantipl != IPL_NONE)
splx(mtx->mtx_oldipl);
}