| .. | .. |
|---|
| 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; |
|---|
| 24 | 25 | |
|---|
| .. | .. |
|---|
| 63 | 64 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
|---|
| 64 | 65 | struct lockdep_map dep_map; |
|---|
| 65 | 66 | #endif |
|---|
| 67 | + ANDROID_OEM_DATA_ARRAY(1, 2); |
|---|
| 66 | 68 | }; |
|---|
| 67 | 69 | |
|---|
| 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 | +}; |
|---|
| 77 | 80 | |
|---|
| 78 | 81 | /* |
|---|
| 79 | 82 | * This is the control structure for tasks blocked on mutex, |
|---|
| .. | .. |
|---|
| 119 | 122 | } while (0) |
|---|
| 120 | 123 | |
|---|
| 121 | 124 | #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 | + } |
|---|
| 124 | 130 | #else |
|---|
| 125 | 131 | # define __DEP_MAP_MUTEX_INITIALIZER(lockname) |
|---|
| 126 | 132 | #endif |
|---|
| .. | .. |
|---|
| 144 | 150 | * |
|---|
| 145 | 151 | * Returns true if the mutex is locked, false if unlocked. |
|---|
| 146 | 152 | */ |
|---|
| 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); |
|---|
| 151 | 154 | |
|---|
| 152 | 155 | /* |
|---|
| 153 | 156 | * 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. |
|---|
| 155 | 158 | */ |
|---|
| 156 | 159 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
|---|
| 157 | 160 | extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass); |
|---|
| .. | .. |
|---|
| 220 | 223 | * - MUTEX_TRYLOCK_SUCCESS - lock acquired, |
|---|
| 221 | 224 | * - MUTEX_TRYLOCK_RECURSIVE - we already owned the lock. |
|---|
| 222 | 225 | */ |
|---|
| 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); |
|---|
| 231 | 228 | |
|---|
| 232 | 229 | #endif /* __LINUX_MUTEX_H */ |
|---|