hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/mutex.h
....@@ -19,8 +19,23 @@
1919 #include <asm/processor.h>
2020 #include <linux/osq_lock.h>
2121 #include <linux/debug_locks.h>
22
+#include <linux/android_vendor.h>
2223
2324 struct ww_acquire_ctx;
25
+
26
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
27
+# define __DEP_MAP_MUTEX_INITIALIZER(lockname) \
28
+ , .dep_map = { \
29
+ .name = #lockname, \
30
+ .wait_type_inner = LD_WAIT_SLEEP, \
31
+ }
32
+#else
33
+# define __DEP_MAP_MUTEX_INITIALIZER(lockname)
34
+#endif
35
+
36
+#ifdef CONFIG_PREEMPT_RT
37
+# include <linux/mutex_rt.h>
38
+#else
2439
2540 /*
2641 * Simple, straightforward mutexes with strict semantics:
....@@ -63,17 +78,11 @@
6378 #ifdef CONFIG_DEBUG_LOCK_ALLOC
6479 struct lockdep_map dep_map;
6580 #endif
81
+ ANDROID_OEM_DATA_ARRAY(1, 2);
6682 };
6783
68
-/*
69
- * Internal helper function; C doesn't allow us to hide it :/
70
- *
71
- * DO NOT USE (outside of mutex code).
72
- */
73
-static inline struct task_struct *__mutex_owner(struct mutex *lock)
74
-{
75
- return (struct task_struct *)(atomic_long_read(&lock->owner) & ~0x07);
76
-}
84
+struct ww_class;
85
+struct ww_acquire_ctx;
7786
7887 /*
7988 * This is the control structure for tasks blocked on mutex,
....@@ -118,13 +127,6 @@
118127 __mutex_init((mutex), #mutex, &__key); \
119128 } while (0)
120129
121
-#ifdef CONFIG_DEBUG_LOCK_ALLOC
122
-# define __DEP_MAP_MUTEX_INITIALIZER(lockname) \
123
- , .dep_map = { .name = #lockname }
124
-#else
125
-# define __DEP_MAP_MUTEX_INITIALIZER(lockname)
126
-#endif
127
-
128130 #define __MUTEX_INITIALIZER(lockname) \
129131 { .owner = ATOMIC_LONG_INIT(0) \
130132 , .wait_lock = __SPIN_LOCK_UNLOCKED(lockname.wait_lock) \
....@@ -144,14 +146,11 @@
144146 *
145147 * Returns true if the mutex is locked, false if unlocked.
146148 */
147
-static inline bool mutex_is_locked(struct mutex *lock)
148
-{
149
- return __mutex_owner(lock) != NULL;
150
-}
149
+extern bool mutex_is_locked(struct mutex *lock);
151150
152151 /*
153152 * See kernel/locking/mutex.c for detailed documentation of these APIs.
154
- * Also see Documentation/locking/mutex-design.txt.
153
+ * Also see Documentation/locking/mutex-design.rst.
155154 */
156155 #ifdef CONFIG_DEBUG_LOCK_ALLOC
157156 extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass);
....@@ -220,13 +219,9 @@
220219 * - MUTEX_TRYLOCK_SUCCESS - lock acquired,
221220 * - MUTEX_TRYLOCK_RECURSIVE - we already owned the lock.
222221 */
223
-static inline /* __deprecated */ __must_check enum mutex_trylock_recursive_enum
224
-mutex_trylock_recursive(struct mutex *lock)
225
-{
226
- if (unlikely(__mutex_owner(lock) == current))
227
- return MUTEX_TRYLOCK_RECURSIVE;
222
+extern /* __deprecated */ __must_check enum mutex_trylock_recursive_enum
223
+mutex_trylock_recursive(struct mutex *lock);
228224
229
- return mutex_trylock(lock);
230
-}
225
+#endif /* !PREEMPT_RT */
231226
232227 #endif /* __LINUX_MUTEX_H */