Lines Matching full:lock
3 * Queue read/write lock
22 #define _QW_LOCKED 0x0ff /* A writer holds the lock */
30 extern void queued_read_lock_slowpath(struct qrwlock *lock);
31 extern void queued_write_lock_slowpath(struct qrwlock *lock);
34 * queued_read_trylock - try to acquire read lock of a queue rwlock
35 * @lock : Pointer to queue rwlock structure
36 * Return: 1 if lock acquired, 0 if failed
38 static inline int queued_read_trylock(struct qrwlock *lock) in queued_read_trylock() argument
42 cnts = atomic_read(&lock->cnts); in queued_read_trylock()
44 cnts = (u32)atomic_add_return_acquire(_QR_BIAS, &lock->cnts); in queued_read_trylock()
47 atomic_sub(_QR_BIAS, &lock->cnts); in queued_read_trylock()
53 * queued_write_trylock - try to acquire write lock of a queue rwlock
54 * @lock : Pointer to queue rwlock structure
55 * Return: 1 if lock acquired, 0 if failed
57 static inline int queued_write_trylock(struct qrwlock *lock) in queued_write_trylock() argument
61 cnts = atomic_read(&lock->cnts); in queued_write_trylock()
65 return likely(atomic_try_cmpxchg_acquire(&lock->cnts, &cnts, in queued_write_trylock()
69 * queued_read_lock - acquire read lock of a queue rwlock
70 * @lock: Pointer to queue rwlock structure
72 static inline void queued_read_lock(struct qrwlock *lock) in queued_read_lock() argument
76 cnts = atomic_add_return_acquire(_QR_BIAS, &lock->cnts); in queued_read_lock()
81 queued_read_lock_slowpath(lock); in queued_read_lock()
85 * queued_write_lock - acquire write lock of a queue rwlock
86 * @lock : Pointer to queue rwlock structure
88 static inline void queued_write_lock(struct qrwlock *lock) in queued_write_lock() argument
91 /* Optimize for the unfair lock case where the fair flag is 0. */ in queued_write_lock()
92 if (likely(atomic_try_cmpxchg_acquire(&lock->cnts, &cnts, _QW_LOCKED))) in queued_write_lock()
95 queued_write_lock_slowpath(lock); in queued_write_lock()
99 * queued_read_unlock - release read lock of a queue rwlock
100 * @lock : Pointer to queue rwlock structure
102 static inline void queued_read_unlock(struct qrwlock *lock) in queued_read_unlock() argument
107 (void)atomic_sub_return_release(_QR_BIAS, &lock->cnts); in queued_read_unlock()
111 * queued_write_unlock - release write lock of a queue rwlock
112 * @lock : Pointer to queue rwlock structure
114 static inline void queued_write_unlock(struct qrwlock *lock) in queued_write_unlock() argument
116 smp_store_release(&lock->wlocked, 0); in queued_write_unlock()