aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-07-08 12:19:54 +1000
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-07-08 12:36:28 +1000
commite74abeb3c34dcbfcf0d1b3c4462178d9c543c3a9 (patch)
treef1d47261313c381bbba3170b86a17d9fe909073e /core
parentbe5a949949cf116025e1c018cd26c4707c669073 (diff)
downloadskiboot-e74abeb3c34dcbfcf0d1b3c4462178d9c543c3a9.zip
skiboot-e74abeb3c34dcbfcf0d1b3c4462178d9c543c3a9.tar.gz
skiboot-e74abeb3c34dcbfcf0d1b3c4462178d9c543c3a9.tar.bz2
lock: Add helper to check if this CPU is already holding a lock
For debug purposes essentially Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'core')
-rw-r--r--core/lock.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/lock.c b/core/lock.c
index fc4bf6b..70fb994 100644
--- a/core/lock.c
+++ b/core/lock.c
@@ -61,6 +61,12 @@ static inline void lock_check(struct lock *l) { };
static inline void unlock_check(struct lock *l) { };
#endif /* DEBUG_LOCKS */
+bool lock_held_by_me(struct lock *l)
+{
+ uint64_t pir64 = this_cpu()->pir;
+
+ return l->lock_val == ((pir64 << 32) | 1);
+}
bool try_lock(struct lock *l)
{