Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 1 | #ifndef __LINUX_RWLOCK_API_SMP_H |
| 2 | #define __LINUX_RWLOCK_API_SMP_H |
| 3 | |
| 4 | #ifndef __LINUX_SPINLOCK_API_SMP_H |
| 5 | # error "please don't include this file directly" |
| 6 | #endif |
| 7 | |
| 8 | /* |
| 9 | * include/linux/rwlock_api_smp.h |
| 10 | * |
| 11 | * spinlock API declarations on SMP (and debug) |
| 12 | * (implemented in kernel/spinlock.c) |
| 13 | * |
| 14 | * portions Copyright 2005, Red Hat, Inc., Ingo Molnar |
| 15 | * Released under the General Public License (GPL). |
| 16 | */ |
| 17 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 18 | void __lockfunc _raw_read_lock(rwlock_t *lock) __acquires(lock); |
| 19 | void __lockfunc _raw_write_lock(rwlock_t *lock) __acquires(lock); |
Minchan Kim | 4a57d6b | 2022-01-21 22:14:10 -0800 | [diff] [blame] | 20 | void __lockfunc _raw_write_lock_nested(rwlock_t *lock, int subclass) __acquires(lock); |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 21 | void __lockfunc _raw_read_lock_bh(rwlock_t *lock) __acquires(lock); |
| 22 | void __lockfunc _raw_write_lock_bh(rwlock_t *lock) __acquires(lock); |
| 23 | void __lockfunc _raw_read_lock_irq(rwlock_t *lock) __acquires(lock); |
| 24 | void __lockfunc _raw_write_lock_irq(rwlock_t *lock) __acquires(lock); |
| 25 | unsigned long __lockfunc _raw_read_lock_irqsave(rwlock_t *lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 26 | __acquires(lock); |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 27 | unsigned long __lockfunc _raw_write_lock_irqsave(rwlock_t *lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 28 | __acquires(lock); |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 29 | int __lockfunc _raw_read_trylock(rwlock_t *lock); |
| 30 | int __lockfunc _raw_write_trylock(rwlock_t *lock); |
| 31 | void __lockfunc _raw_read_unlock(rwlock_t *lock) __releases(lock); |
| 32 | void __lockfunc _raw_write_unlock(rwlock_t *lock) __releases(lock); |
| 33 | void __lockfunc _raw_read_unlock_bh(rwlock_t *lock) __releases(lock); |
| 34 | void __lockfunc _raw_write_unlock_bh(rwlock_t *lock) __releases(lock); |
| 35 | void __lockfunc _raw_read_unlock_irq(rwlock_t *lock) __releases(lock); |
| 36 | void __lockfunc _raw_write_unlock_irq(rwlock_t *lock) __releases(lock); |
| 37 | void __lockfunc |
| 38 | _raw_read_unlock_irqrestore(rwlock_t *lock, unsigned long flags) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 39 | __releases(lock); |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 40 | void __lockfunc |
| 41 | _raw_write_unlock_irqrestore(rwlock_t *lock, unsigned long flags) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 42 | __releases(lock); |
| 43 | |
| 44 | #ifdef CONFIG_INLINE_READ_LOCK |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 45 | #define _raw_read_lock(lock) __raw_read_lock(lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 46 | #endif |
| 47 | |
| 48 | #ifdef CONFIG_INLINE_WRITE_LOCK |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 49 | #define _raw_write_lock(lock) __raw_write_lock(lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 50 | #endif |
| 51 | |
| 52 | #ifdef CONFIG_INLINE_READ_LOCK_BH |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 53 | #define _raw_read_lock_bh(lock) __raw_read_lock_bh(lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 54 | #endif |
| 55 | |
| 56 | #ifdef CONFIG_INLINE_WRITE_LOCK_BH |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 57 | #define _raw_write_lock_bh(lock) __raw_write_lock_bh(lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 58 | #endif |
| 59 | |
| 60 | #ifdef CONFIG_INLINE_READ_LOCK_IRQ |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 61 | #define _raw_read_lock_irq(lock) __raw_read_lock_irq(lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 62 | #endif |
| 63 | |
| 64 | #ifdef CONFIG_INLINE_WRITE_LOCK_IRQ |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 65 | #define _raw_write_lock_irq(lock) __raw_write_lock_irq(lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 66 | #endif |
| 67 | |
| 68 | #ifdef CONFIG_INLINE_READ_LOCK_IRQSAVE |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 69 | #define _raw_read_lock_irqsave(lock) __raw_read_lock_irqsave(lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 70 | #endif |
| 71 | |
| 72 | #ifdef CONFIG_INLINE_WRITE_LOCK_IRQSAVE |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 73 | #define _raw_write_lock_irqsave(lock) __raw_write_lock_irqsave(lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 74 | #endif |
| 75 | |
| 76 | #ifdef CONFIG_INLINE_READ_TRYLOCK |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 77 | #define _raw_read_trylock(lock) __raw_read_trylock(lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 78 | #endif |
| 79 | |
| 80 | #ifdef CONFIG_INLINE_WRITE_TRYLOCK |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 81 | #define _raw_write_trylock(lock) __raw_write_trylock(lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 82 | #endif |
| 83 | |
| 84 | #ifdef CONFIG_INLINE_READ_UNLOCK |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 85 | #define _raw_read_unlock(lock) __raw_read_unlock(lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 86 | #endif |
| 87 | |
| 88 | #ifdef CONFIG_INLINE_WRITE_UNLOCK |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 89 | #define _raw_write_unlock(lock) __raw_write_unlock(lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 90 | #endif |
| 91 | |
| 92 | #ifdef CONFIG_INLINE_READ_UNLOCK_BH |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 93 | #define _raw_read_unlock_bh(lock) __raw_read_unlock_bh(lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 94 | #endif |
| 95 | |
| 96 | #ifdef CONFIG_INLINE_WRITE_UNLOCK_BH |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 97 | #define _raw_write_unlock_bh(lock) __raw_write_unlock_bh(lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 98 | #endif |
| 99 | |
| 100 | #ifdef CONFIG_INLINE_READ_UNLOCK_IRQ |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 101 | #define _raw_read_unlock_irq(lock) __raw_read_unlock_irq(lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 102 | #endif |
| 103 | |
| 104 | #ifdef CONFIG_INLINE_WRITE_UNLOCK_IRQ |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 105 | #define _raw_write_unlock_irq(lock) __raw_write_unlock_irq(lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 106 | #endif |
| 107 | |
| 108 | #ifdef CONFIG_INLINE_READ_UNLOCK_IRQRESTORE |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 109 | #define _raw_read_unlock_irqrestore(lock, flags) \ |
| 110 | __raw_read_unlock_irqrestore(lock, flags) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 111 | #endif |
| 112 | |
| 113 | #ifdef CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 114 | #define _raw_write_unlock_irqrestore(lock, flags) \ |
| 115 | __raw_write_unlock_irqrestore(lock, flags) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 116 | #endif |
| 117 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 118 | static inline int __raw_read_trylock(rwlock_t *lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 119 | { |
| 120 | preempt_disable(); |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 121 | if (do_raw_read_trylock(lock)) { |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 122 | rwlock_acquire_read(&lock->dep_map, 0, 1, _RET_IP_); |
| 123 | return 1; |
| 124 | } |
| 125 | preempt_enable(); |
| 126 | return 0; |
| 127 | } |
| 128 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 129 | static inline int __raw_write_trylock(rwlock_t *lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 130 | { |
| 131 | preempt_disable(); |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 132 | if (do_raw_write_trylock(lock)) { |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 133 | rwlock_acquire(&lock->dep_map, 0, 1, _RET_IP_); |
| 134 | return 1; |
| 135 | } |
| 136 | preempt_enable(); |
| 137 | return 0; |
| 138 | } |
| 139 | |
| 140 | /* |
| 141 | * If lockdep is enabled then we use the non-preemption spin-ops |
| 142 | * even on CONFIG_PREEMPT, because lockdep assumes that interrupts are |
| 143 | * not re-enabled during lock-acquire (which the preempt-spin-ops do): |
| 144 | */ |
| 145 | #if !defined(CONFIG_GENERIC_LOCKBREAK) || defined(CONFIG_DEBUG_LOCK_ALLOC) |
| 146 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 147 | static inline void __raw_read_lock(rwlock_t *lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 148 | { |
| 149 | preempt_disable(); |
| 150 | rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_); |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 151 | LOCK_CONTENDED(lock, do_raw_read_trylock, do_raw_read_lock); |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 152 | } |
| 153 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 154 | static inline unsigned long __raw_read_lock_irqsave(rwlock_t *lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 155 | { |
| 156 | unsigned long flags; |
| 157 | |
| 158 | local_irq_save(flags); |
| 159 | preempt_disable(); |
| 160 | rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_); |
Arnd Bergmann | f98a3dc | 2021-10-22 13:59:38 +0200 | [diff] [blame] | 161 | LOCK_CONTENDED(lock, do_raw_read_trylock, do_raw_read_lock); |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 162 | return flags; |
| 163 | } |
| 164 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 165 | static inline void __raw_read_lock_irq(rwlock_t *lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 166 | { |
| 167 | local_irq_disable(); |
| 168 | preempt_disable(); |
| 169 | rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_); |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 170 | LOCK_CONTENDED(lock, do_raw_read_trylock, do_raw_read_lock); |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 171 | } |
| 172 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 173 | static inline void __raw_read_lock_bh(rwlock_t *lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 174 | { |
Peter Zijlstra | 9ea4c38 | 2013-11-19 16:13:38 +0100 | [diff] [blame] | 175 | __local_bh_disable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET); |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 176 | rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_); |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 177 | LOCK_CONTENDED(lock, do_raw_read_trylock, do_raw_read_lock); |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 178 | } |
| 179 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 180 | static inline unsigned long __raw_write_lock_irqsave(rwlock_t *lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 181 | { |
| 182 | unsigned long flags; |
| 183 | |
| 184 | local_irq_save(flags); |
| 185 | preempt_disable(); |
| 186 | rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_); |
Arnd Bergmann | f98a3dc | 2021-10-22 13:59:38 +0200 | [diff] [blame] | 187 | LOCK_CONTENDED(lock, do_raw_write_trylock, do_raw_write_lock); |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 188 | return flags; |
| 189 | } |
| 190 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 191 | static inline void __raw_write_lock_irq(rwlock_t *lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 192 | { |
| 193 | local_irq_disable(); |
| 194 | preempt_disable(); |
| 195 | rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_); |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 196 | LOCK_CONTENDED(lock, do_raw_write_trylock, do_raw_write_lock); |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 197 | } |
| 198 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 199 | static inline void __raw_write_lock_bh(rwlock_t *lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 200 | { |
Peter Zijlstra | 9ea4c38 | 2013-11-19 16:13:38 +0100 | [diff] [blame] | 201 | __local_bh_disable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET); |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 202 | rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_); |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 203 | LOCK_CONTENDED(lock, do_raw_write_trylock, do_raw_write_lock); |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 204 | } |
| 205 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 206 | static inline void __raw_write_lock(rwlock_t *lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 207 | { |
| 208 | preempt_disable(); |
| 209 | rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_); |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 210 | LOCK_CONTENDED(lock, do_raw_write_trylock, do_raw_write_lock); |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 211 | } |
| 212 | |
Minchan Kim | 4a57d6b | 2022-01-21 22:14:10 -0800 | [diff] [blame] | 213 | static inline void __raw_write_lock_nested(rwlock_t *lock, int subclass) |
| 214 | { |
| 215 | preempt_disable(); |
| 216 | rwlock_acquire(&lock->dep_map, subclass, 0, _RET_IP_); |
| 217 | LOCK_CONTENDED(lock, do_raw_write_trylock, do_raw_write_lock); |
| 218 | } |
| 219 | |
Cheng Jian | f791dd25 | 2017-11-03 18:59:48 +0800 | [diff] [blame] | 220 | #endif /* !CONFIG_GENERIC_LOCKBREAK || CONFIG_DEBUG_LOCK_ALLOC */ |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 221 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 222 | static inline void __raw_write_unlock(rwlock_t *lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 223 | { |
Qian Cai | 5facae4 | 2019-09-19 12:09:40 -0400 | [diff] [blame] | 224 | rwlock_release(&lock->dep_map, _RET_IP_); |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 225 | do_raw_write_unlock(lock); |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 226 | preempt_enable(); |
| 227 | } |
| 228 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 229 | static inline void __raw_read_unlock(rwlock_t *lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 230 | { |
Qian Cai | 5facae4 | 2019-09-19 12:09:40 -0400 | [diff] [blame] | 231 | rwlock_release(&lock->dep_map, _RET_IP_); |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 232 | do_raw_read_unlock(lock); |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 233 | preempt_enable(); |
| 234 | } |
| 235 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 236 | static inline void |
| 237 | __raw_read_unlock_irqrestore(rwlock_t *lock, unsigned long flags) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 238 | { |
Qian Cai | 5facae4 | 2019-09-19 12:09:40 -0400 | [diff] [blame] | 239 | rwlock_release(&lock->dep_map, _RET_IP_); |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 240 | do_raw_read_unlock(lock); |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 241 | local_irq_restore(flags); |
| 242 | preempt_enable(); |
| 243 | } |
| 244 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 245 | static inline void __raw_read_unlock_irq(rwlock_t *lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 246 | { |
Qian Cai | 5facae4 | 2019-09-19 12:09:40 -0400 | [diff] [blame] | 247 | rwlock_release(&lock->dep_map, _RET_IP_); |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 248 | do_raw_read_unlock(lock); |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 249 | local_irq_enable(); |
| 250 | preempt_enable(); |
| 251 | } |
| 252 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 253 | static inline void __raw_read_unlock_bh(rwlock_t *lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 254 | { |
Qian Cai | 5facae4 | 2019-09-19 12:09:40 -0400 | [diff] [blame] | 255 | rwlock_release(&lock->dep_map, _RET_IP_); |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 256 | do_raw_read_unlock(lock); |
Peter Zijlstra | 9ea4c38 | 2013-11-19 16:13:38 +0100 | [diff] [blame] | 257 | __local_bh_enable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET); |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 258 | } |
| 259 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 260 | static inline void __raw_write_unlock_irqrestore(rwlock_t *lock, |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 261 | unsigned long flags) |
| 262 | { |
Qian Cai | 5facae4 | 2019-09-19 12:09:40 -0400 | [diff] [blame] | 263 | rwlock_release(&lock->dep_map, _RET_IP_); |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 264 | do_raw_write_unlock(lock); |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 265 | local_irq_restore(flags); |
| 266 | preempt_enable(); |
| 267 | } |
| 268 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 269 | static inline void __raw_write_unlock_irq(rwlock_t *lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 270 | { |
Qian Cai | 5facae4 | 2019-09-19 12:09:40 -0400 | [diff] [blame] | 271 | rwlock_release(&lock->dep_map, _RET_IP_); |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 272 | do_raw_write_unlock(lock); |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 273 | local_irq_enable(); |
| 274 | preempt_enable(); |
| 275 | } |
| 276 | |
Thomas Gleixner | 9c1721a | 2009-12-03 21:52:18 +0100 | [diff] [blame] | 277 | static inline void __raw_write_unlock_bh(rwlock_t *lock) |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 278 | { |
Qian Cai | 5facae4 | 2019-09-19 12:09:40 -0400 | [diff] [blame] | 279 | rwlock_release(&lock->dep_map, _RET_IP_); |
Thomas Gleixner | 9828ea9 | 2009-12-03 20:55:53 +0100 | [diff] [blame] | 280 | do_raw_write_unlock(lock); |
Peter Zijlstra | 9ea4c38 | 2013-11-19 16:13:38 +0100 | [diff] [blame] | 281 | __local_bh_enable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET); |
Thomas Gleixner | 6b6b479 | 2009-11-16 18:48:37 +0100 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | #endif /* __LINUX_RWLOCK_API_SMP_H */ |