.. | .. |
---|
19 | 19 | #include <asm/processor.h> |
---|
20 | 20 | #include <linux/osq_lock.h> |
---|
21 | 21 | #include <linux/debug_locks.h> |
---|
| 22 | +#include <linux/android_vendor.h> |
---|
22 | 23 | |
---|
23 | 24 | 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 |
---|
24 | 39 | |
---|
25 | 40 | /* |
---|
26 | 41 | * Simple, straightforward mutexes with strict semantics: |
---|
.. | .. |
---|
63 | 78 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
---|
64 | 79 | struct lockdep_map dep_map; |
---|
65 | 80 | #endif |
---|
| 81 | + ANDROID_OEM_DATA_ARRAY(1, 2); |
---|
66 | 82 | }; |
---|
67 | 83 | |
---|
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; |
---|
77 | 86 | |
---|
78 | 87 | /* |
---|
79 | 88 | * This is the control structure for tasks blocked on mutex, |
---|
.. | .. |
---|
118 | 127 | __mutex_init((mutex), #mutex, &__key); \ |
---|
119 | 128 | } while (0) |
---|
120 | 129 | |
---|
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 | | - |
---|
128 | 130 | #define __MUTEX_INITIALIZER(lockname) \ |
---|
129 | 131 | { .owner = ATOMIC_LONG_INIT(0) \ |
---|
130 | 132 | , .wait_lock = __SPIN_LOCK_UNLOCKED(lockname.wait_lock) \ |
---|
.. | .. |
---|
144 | 146 | * |
---|
145 | 147 | * Returns true if the mutex is locked, false if unlocked. |
---|
146 | 148 | */ |
---|
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); |
---|
151 | 150 | |
---|
152 | 151 | /* |
---|
153 | 152 | * 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. |
---|
155 | 154 | */ |
---|
156 | 155 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
---|
157 | 156 | extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass); |
---|
.. | .. |
---|
220 | 219 | * - MUTEX_TRYLOCK_SUCCESS - lock acquired, |
---|
221 | 220 | * - MUTEX_TRYLOCK_RECURSIVE - we already owned the lock. |
---|
222 | 221 | */ |
---|
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); |
---|
228 | 224 | |
---|
229 | | - return mutex_trylock(lock); |
---|
230 | | -} |
---|
| 225 | +#endif /* !PREEMPT_RT */ |
---|
231 | 226 | |
---|
232 | 227 | #endif /* __LINUX_MUTEX_H */ |
---|