45 lines
1.3 KiB
Diff
45 lines
1.3 KiB
Diff
|
From b0c82e8f48f2fd6326ba8d03f9a0c3e8c1c0f54b Mon Sep 17 00:00:00 2001
|
||
|
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
||
|
Date: Thu, 21 Sep 2017 14:39:56 +0200
|
||
|
Subject: [PATCH 340/365] rt/locking: allow recursive local_trylock()
|
||
|
|
||
|
required for following networking patch which does recursive try-lock.
|
||
|
While at it, add the !RT version of it because it did not yet exist.
|
||
|
|
||
|
Cc: stable-rt@vger.kernel.org
|
||
|
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
||
|
---
|
||
|
include/linux/locallock.h | 9 +++++++++
|
||
|
1 file changed, 9 insertions(+)
|
||
|
|
||
|
diff --git a/include/linux/locallock.h b/include/linux/locallock.h
|
||
|
index 845c77f1a5ca..280f884a05a3 100644
|
||
|
--- a/include/linux/locallock.h
|
||
|
+++ b/include/linux/locallock.h
|
||
|
@@ -77,6 +77,9 @@ static inline int __local_trylock(struct local_irq_lock *lv)
|
||
|
lv->owner = current;
|
||
|
lv->nestcnt = 1;
|
||
|
return 1;
|
||
|
+ } else if (lv->owner == current) {
|
||
|
+ lv->nestcnt++;
|
||
|
+ return 1;
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
@@ -250,6 +253,12 @@ static inline int __local_unlock_irqrestore(struct local_irq_lock *lv,
|
||
|
|
||
|
static inline void local_irq_lock_init(int lvar) { }
|
||
|
|
||
|
+#define local_trylock(lvar) \
|
||
|
+ ({ \
|
||
|
+ preempt_disable(); \
|
||
|
+ 1; \
|
||
|
+ })
|
||
|
+
|
||
|
#define local_lock(lvar) preempt_disable()
|
||
|
#define local_unlock(lvar) preempt_enable()
|
||
|
#define local_lock_irq(lvar) local_irq_disable()
|
||
|
--
|
||
|
2.28.0
|
||
|
|