2012-06-17 19:52:06 +00:00
|
|
|
From 7e50415705bde73113538b2095e3876b85f001ca Mon Sep 17 00:00:00 2001
|
2011-11-20 00:01:55 +00:00
|
|
|
From: Thomas Gleixner <tglx@linutronix.de>
|
|
|
|
Date: Wed, 29 Jun 2011 20:56:22 +0200
|
2012-06-17 19:52:06 +00:00
|
|
|
Subject: [178/254] rt-add-rt-to-mutex-headers.patch
|
2011-11-20 00:01:55 +00:00
|
|
|
|
|
|
|
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
|
|
|
|
---
|
2012-06-17 19:52:06 +00:00
|
|
|
include/linux/mutex.h | 21 ++++++++----
|
|
|
|
include/linux/mutex_rt.h | 84 ++++++++++++++++++++++++++++++++++++++++++++++
|
2011-11-20 00:01:55 +00:00
|
|
|
2 files changed, 98 insertions(+), 7 deletions(-)
|
2012-06-17 19:52:06 +00:00
|
|
|
create mode 100644 include/linux/mutex_rt.h
|
2011-11-20 00:01:55 +00:00
|
|
|
|
2012-06-17 19:52:06 +00:00
|
|
|
diff --git a/include/linux/mutex.h b/include/linux/mutex.h
|
|
|
|
index 9121595..bdf1da2 100644
|
|
|
|
--- a/include/linux/mutex.h
|
|
|
|
+++ b/include/linux/mutex.h
|
2011-11-20 00:01:55 +00:00
|
|
|
@@ -17,6 +17,17 @@
|
|
|
|
|
|
|
|
#include <linux/atomic.h>
|
|
|
|
|
|
|
|
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
|
|
|
+# define __DEP_MAP_MUTEX_INITIALIZER(lockname) \
|
|
|
|
+ , .dep_map = { .name = #lockname }
|
|
|
|
+#else
|
|
|
|
+# define __DEP_MAP_MUTEX_INITIALIZER(lockname)
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+#ifdef CONFIG_PREEMPT_RT_FULL
|
|
|
|
+# include <linux/mutex_rt.h>
|
|
|
|
+#else
|
|
|
|
+
|
|
|
|
/*
|
|
|
|
* Simple, straightforward mutexes with strict semantics:
|
|
|
|
*
|
|
|
|
@@ -95,13 +106,6 @@ do { \
|
|
|
|
static inline void mutex_destroy(struct mutex *lock) {}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
-#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
|
|
|
-# define __DEP_MAP_MUTEX_INITIALIZER(lockname) \
|
|
|
|
- , .dep_map = { .name = #lockname }
|
|
|
|
-#else
|
|
|
|
-# define __DEP_MAP_MUTEX_INITIALIZER(lockname)
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
#define __MUTEX_INITIALIZER(lockname) \
|
|
|
|
{ .count = ATOMIC_INIT(1) \
|
|
|
|
, .wait_lock = __SPIN_LOCK_UNLOCKED(lockname.wait_lock) \
|
2012-06-17 19:52:06 +00:00
|
|
|
@@ -167,6 +171,9 @@ extern int __must_check mutex_lock_killable(struct mutex *lock);
|
2011-11-20 00:01:55 +00:00
|
|
|
*/
|
|
|
|
extern int mutex_trylock(struct mutex *lock);
|
|
|
|
extern void mutex_unlock(struct mutex *lock);
|
|
|
|
+
|
|
|
|
+#endif /* !PREEMPT_RT_FULL */
|
|
|
|
+
|
|
|
|
extern int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *lock);
|
|
|
|
|
|
|
|
#ifndef CONFIG_HAVE_ARCH_MUTEX_CPU_RELAX
|
2012-06-17 19:52:06 +00:00
|
|
|
diff --git a/include/linux/mutex_rt.h b/include/linux/mutex_rt.h
|
|
|
|
new file mode 100644
|
|
|
|
index 0000000..c38a44b
|
2011-11-20 00:01:55 +00:00
|
|
|
--- /dev/null
|
2012-06-17 19:52:06 +00:00
|
|
|
+++ b/include/linux/mutex_rt.h
|
2011-11-20 00:01:55 +00:00
|
|
|
@@ -0,0 +1,84 @@
|
|
|
|
+#ifndef __LINUX_MUTEX_RT_H
|
|
|
|
+#define __LINUX_MUTEX_RT_H
|
|
|
|
+
|
|
|
|
+#ifndef __LINUX_MUTEX_H
|
|
|
|
+#error "Please include mutex.h"
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+#include <linux/rtmutex.h>
|
|
|
|
+
|
|
|
|
+/* FIXME: Just for __lockfunc */
|
|
|
|
+#include <linux/spinlock.h>
|
|
|
|
+
|
|
|
|
+struct mutex {
|
|
|
|
+ struct rt_mutex lock;
|
|
|
|
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
|
|
|
+ struct lockdep_map dep_map;
|
|
|
|
+#endif
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+#define __MUTEX_INITIALIZER(mutexname) \
|
|
|
|
+ { \
|
|
|
|
+ .lock = __RT_MUTEX_INITIALIZER(mutexname.lock) \
|
|
|
|
+ __DEP_MAP_MUTEX_INITIALIZER(mutexname) \
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+#define DEFINE_MUTEX(mutexname) \
|
|
|
|
+ struct mutex mutexname = __MUTEX_INITIALIZER(mutexname)
|
|
|
|
+
|
|
|
|
+extern void __mutex_do_init(struct mutex *lock, const char *name, struct lock_class_key *key);
|
|
|
|
+extern void __lockfunc _mutex_lock(struct mutex *lock);
|
|
|
|
+extern int __lockfunc _mutex_lock_interruptible(struct mutex *lock);
|
|
|
|
+extern int __lockfunc _mutex_lock_killable(struct mutex *lock);
|
|
|
|
+extern void __lockfunc _mutex_lock_nested(struct mutex *lock, int subclass);
|
|
|
|
+extern void __lockfunc _mutex_lock_nest_lock(struct mutex *lock, struct lockdep_map *nest_lock);
|
|
|
|
+extern int __lockfunc _mutex_lock_interruptible_nested(struct mutex *lock, int subclass);
|
|
|
|
+extern int __lockfunc _mutex_lock_killable_nested(struct mutex *lock, int subclass);
|
|
|
|
+extern int __lockfunc _mutex_trylock(struct mutex *lock);
|
|
|
|
+extern void __lockfunc _mutex_unlock(struct mutex *lock);
|
|
|
|
+
|
|
|
|
+#define mutex_is_locked(l) rt_mutex_is_locked(&(l)->lock)
|
|
|
|
+#define mutex_lock(l) _mutex_lock(l)
|
|
|
|
+#define mutex_lock_interruptible(l) _mutex_lock_interruptible(l)
|
|
|
|
+#define mutex_lock_killable(l) _mutex_lock_killable(l)
|
|
|
|
+#define mutex_trylock(l) _mutex_trylock(l)
|
|
|
|
+#define mutex_unlock(l) _mutex_unlock(l)
|
|
|
|
+#define mutex_destroy(l) rt_mutex_destroy(&(l)->lock)
|
|
|
|
+
|
|
|
|
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
|
|
|
+# define mutex_lock_nested(l, s) _mutex_lock_nested(l, s)
|
|
|
|
+# define mutex_lock_interruptible_nested(l, s) \
|
|
|
|
+ _mutex_lock_interruptible_nested(l, s)
|
|
|
|
+# define mutex_lock_killable_nested(l, s) \
|
|
|
|
+ _mutex_lock_killable_nested(l, s)
|
|
|
|
+
|
|
|
|
+# define mutex_lock_nest_lock(lock, nest_lock) \
|
|
|
|
+do { \
|
|
|
|
+ typecheck(struct lockdep_map *, &(nest_lock)->dep_map); \
|
|
|
|
+ _mutex_lock_nest_lock(lock, &(nest_lock)->dep_map); \
|
|
|
|
+} while (0)
|
|
|
|
+
|
|
|
|
+#else
|
|
|
|
+# define mutex_lock_nested(l, s) _mutex_lock(l)
|
|
|
|
+# define mutex_lock_interruptible_nested(l, s) \
|
|
|
|
+ _mutex_lock_interruptible(l)
|
|
|
|
+# define mutex_lock_killable_nested(l, s) \
|
|
|
|
+ _mutex_lock_killable(l)
|
|
|
|
+# define mutex_lock_nest_lock(lock, nest_lock) mutex_lock(lock)
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+# define mutex_init(mutex) \
|
|
|
|
+do { \
|
|
|
|
+ static struct lock_class_key __key; \
|
|
|
|
+ \
|
|
|
|
+ rt_mutex_init(&(mutex)->lock); \
|
|
|
|
+ __mutex_do_init((mutex), #mutex, &__key); \
|
|
|
|
+} while (0)
|
|
|
|
+
|
|
|
|
+# define __mutex_init(mutex, name, key) \
|
|
|
|
+do { \
|
|
|
|
+ rt_mutex_init(&(mutex)->lock); \
|
|
|
|
+ __mutex_do_init((mutex), name, key); \
|
|
|
|
+} while (0)
|
|
|
|
+
|
|
|
|
+#endif
|