hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/include/linux/mutex.h
....@@ -19,6 +19,7 @@
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;
2425
....@@ -63,17 +64,19 @@
6364 #ifdef CONFIG_DEBUG_LOCK_ALLOC
6465 struct lockdep_map dep_map;
6566 #endif
67
+ ANDROID_OEM_DATA_ARRAY(1, 2);
6668 };
6769
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
-}
70
+struct ww_class;
71
+struct ww_acquire_ctx;
72
+
73
+struct ww_mutex {
74
+ struct mutex base;
75
+ struct ww_acquire_ctx *ctx;
76
+#ifdef CONFIG_DEBUG_MUTEXES
77
+ struct ww_class *ww_class;
78
+#endif
79
+};
7780
7881 /*
7982 * This is the control structure for tasks blocked on mutex,
....@@ -119,8 +122,11 @@
119122 } while (0)
120123
121124 #ifdef CONFIG_DEBUG_LOCK_ALLOC
122
-# define __DEP_MAP_MUTEX_INITIALIZER(lockname) \
123
- , .dep_map = { .name = #lockname }
125
+# define __DEP_MAP_MUTEX_INITIALIZER(lockname) \
126
+ , .dep_map = { \
127
+ .name = #lockname, \
128
+ .wait_type_inner = LD_WAIT_SLEEP, \
129
+ }
124130 #else
125131 # define __DEP_MAP_MUTEX_INITIALIZER(lockname)
126132 #endif
....@@ -144,14 +150,11 @@
144150 *
145151 * Returns true if the mutex is locked, false if unlocked.
146152 */
147
-static inline bool mutex_is_locked(struct mutex *lock)
148
-{
149
- return __mutex_owner(lock) != NULL;
150
-}
153
+extern bool mutex_is_locked(struct mutex *lock);
151154
152155 /*
153156 * See kernel/locking/mutex.c for detailed documentation of these APIs.
154
- * Also see Documentation/locking/mutex-design.txt.
157
+ * Also see Documentation/locking/mutex-design.rst.
155158 */
156159 #ifdef CONFIG_DEBUG_LOCK_ALLOC
157160 extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass);
....@@ -220,13 +223,7 @@
220223 * - MUTEX_TRYLOCK_SUCCESS - lock acquired,
221224 * - MUTEX_TRYLOCK_RECURSIVE - we already owned the lock.
222225 */
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;
228
-
229
- return mutex_trylock(lock);
230
-}
226
+extern /* __deprecated */ __must_check enum mutex_trylock_recursive_enum
227
+mutex_trylock_recursive(struct mutex *lock);
231228
232229 #endif /* __LINUX_MUTEX_H */