Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (2004) Linus Torvalds |
| 3 | * |
| 4 | * Author: Zwane Mwaikambo <zwane@fsmlabs.com> |
| 5 | * |
Ingo Molnar | fb1c8f9 | 2005-09-10 00:25:56 -0700 | [diff] [blame] | 6 | * Copyright (2004, 2005) Ingo Molnar |
| 7 | * |
| 8 | * This file contains the spinlock/rwlock implementations for the |
| 9 | * SMP and the DEBUG_SPINLOCK cases. (UP-nondebug inlines them) |
Andi Kleen | 0cb91a2 | 2006-09-26 10:52:28 +0200 | [diff] [blame] | 10 | * |
| 11 | * Note that some architectures have special knowledge about the |
| 12 | * stack frames of these functions in their profile_pc. If you |
| 13 | * change anything significant here that could change the stack |
| 14 | * frame contact the architecture maintainers. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/linkage.h> |
| 18 | #include <linux/preempt.h> |
| 19 | #include <linux/spinlock.h> |
| 20 | #include <linux/interrupt.h> |
Ingo Molnar | 8a25d5d | 2006-07-03 00:24:54 -0700 | [diff] [blame] | 21 | #include <linux/debug_locks.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include <linux/module.h> |
| 23 | |
Thomas Gleixner | 8e13c7b | 2009-11-09 15:21:41 +0000 | [diff] [blame] | 24 | /* |
| 25 | * If lockdep is enabled then we use the non-preemption spin-ops |
| 26 | * even on CONFIG_PREEMPT, because lockdep assumes that interrupts are |
| 27 | * not re-enabled during lock-acquire (which the preempt-spin-ops do): |
| 28 | */ |
| 29 | #if !defined(CONFIG_GENERIC_LOCKBREAK) || defined(CONFIG_DEBUG_LOCK_ALLOC) |
| 30 | /* |
| 31 | * The __lock_function inlines are taken from |
| 32 | * include/linux/spinlock_api_smp.h |
| 33 | */ |
| 34 | #else |
| 35 | /* |
| 36 | * We build the __lock_function inlines here. They are too large for |
| 37 | * inlining all over the place, but here is only one user per function |
| 38 | * which embedds them into the calling _lock_function below. |
| 39 | * |
| 40 | * This could be a long-held lock. We both prepare to spin for a long |
| 41 | * time (making _this_ CPU preemptable if possible), and we also signal |
| 42 | * towards that other CPU that it should break the lock ASAP. |
| 43 | */ |
| 44 | #define BUILD_LOCK_OPS(op, locktype) \ |
| 45 | void __lockfunc __##op##_lock(locktype##_t *lock) \ |
| 46 | { \ |
| 47 | for (;;) { \ |
| 48 | preempt_disable(); \ |
| 49 | if (likely(_raw_##op##_trylock(lock))) \ |
| 50 | break; \ |
| 51 | preempt_enable(); \ |
| 52 | \ |
| 53 | if (!(lock)->break_lock) \ |
| 54 | (lock)->break_lock = 1; \ |
| 55 | while (!op##_can_lock(lock) && (lock)->break_lock) \ |
| 56 | _raw_##op##_relax(&lock->raw_lock); \ |
| 57 | } \ |
| 58 | (lock)->break_lock = 0; \ |
| 59 | } \ |
| 60 | \ |
| 61 | unsigned long __lockfunc __##op##_lock_irqsave(locktype##_t *lock) \ |
| 62 | { \ |
| 63 | unsigned long flags; \ |
| 64 | \ |
| 65 | for (;;) { \ |
| 66 | preempt_disable(); \ |
| 67 | local_irq_save(flags); \ |
| 68 | if (likely(_raw_##op##_trylock(lock))) \ |
| 69 | break; \ |
| 70 | local_irq_restore(flags); \ |
| 71 | preempt_enable(); \ |
| 72 | \ |
| 73 | if (!(lock)->break_lock) \ |
| 74 | (lock)->break_lock = 1; \ |
| 75 | while (!op##_can_lock(lock) && (lock)->break_lock) \ |
| 76 | _raw_##op##_relax(&lock->raw_lock); \ |
| 77 | } \ |
| 78 | (lock)->break_lock = 0; \ |
| 79 | return flags; \ |
| 80 | } \ |
| 81 | \ |
| 82 | void __lockfunc __##op##_lock_irq(locktype##_t *lock) \ |
| 83 | { \ |
| 84 | _##op##_lock_irqsave(lock); \ |
| 85 | } \ |
| 86 | \ |
| 87 | void __lockfunc __##op##_lock_bh(locktype##_t *lock) \ |
| 88 | { \ |
| 89 | unsigned long flags; \ |
| 90 | \ |
| 91 | /* */ \ |
| 92 | /* Careful: we must exclude softirqs too, hence the */ \ |
| 93 | /* irq-disabling. We use the generic preemption-aware */ \ |
| 94 | /* function: */ \ |
| 95 | /**/ \ |
| 96 | flags = _##op##_lock_irqsave(lock); \ |
| 97 | local_bh_disable(); \ |
| 98 | local_irq_restore(flags); \ |
| 99 | } \ |
| 100 | |
| 101 | /* |
| 102 | * Build preemption-friendly versions of the following |
| 103 | * lock-spinning functions: |
| 104 | * |
| 105 | * __[spin|read|write]_lock() |
| 106 | * __[spin|read|write]_lock_irq() |
| 107 | * __[spin|read|write]_lock_irqsave() |
| 108 | * __[spin|read|write]_lock_bh() |
| 109 | */ |
| 110 | BUILD_LOCK_OPS(spin, spinlock); |
| 111 | BUILD_LOCK_OPS(read, rwlock); |
| 112 | BUILD_LOCK_OPS(write, rwlock); |
| 113 | |
| 114 | #endif |
| 115 | |
| 116 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
| 117 | |
| 118 | void __lockfunc _spin_lock_nested(spinlock_t *lock, int subclass) |
| 119 | { |
| 120 | preempt_disable(); |
| 121 | spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_); |
| 122 | LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock); |
| 123 | } |
| 124 | EXPORT_SYMBOL(_spin_lock_nested); |
| 125 | |
| 126 | unsigned long __lockfunc _spin_lock_irqsave_nested(spinlock_t *lock, |
| 127 | int subclass) |
| 128 | { |
| 129 | unsigned long flags; |
| 130 | |
| 131 | local_irq_save(flags); |
| 132 | preempt_disable(); |
| 133 | spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_); |
| 134 | LOCK_CONTENDED_FLAGS(lock, _raw_spin_trylock, _raw_spin_lock, |
| 135 | _raw_spin_lock_flags, &flags); |
| 136 | return flags; |
| 137 | } |
| 138 | EXPORT_SYMBOL(_spin_lock_irqsave_nested); |
| 139 | |
| 140 | void __lockfunc _spin_lock_nest_lock(spinlock_t *lock, |
| 141 | struct lockdep_map *nest_lock) |
| 142 | { |
| 143 | preempt_disable(); |
| 144 | spin_acquire_nest(&lock->dep_map, 0, 0, nest_lock, _RET_IP_); |
| 145 | LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock); |
| 146 | } |
| 147 | EXPORT_SYMBOL(_spin_lock_nest_lock); |
| 148 | |
| 149 | #endif |
| 150 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 151 | #ifndef CONFIG_INLINE_SPIN_TRYLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | int __lockfunc _spin_trylock(spinlock_t *lock) |
| 153 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 154 | return __spin_trylock(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | } |
| 156 | EXPORT_SYMBOL(_spin_trylock); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 157 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 159 | #ifndef CONFIG_INLINE_READ_TRYLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | int __lockfunc _read_trylock(rwlock_t *lock) |
| 161 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 162 | return __read_trylock(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | } |
| 164 | EXPORT_SYMBOL(_read_trylock); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 165 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 167 | #ifndef CONFIG_INLINE_WRITE_TRYLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | int __lockfunc _write_trylock(rwlock_t *lock) |
| 169 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 170 | return __write_trylock(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | } |
| 172 | EXPORT_SYMBOL(_write_trylock); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 173 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 175 | #ifndef CONFIG_INLINE_READ_LOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | void __lockfunc _read_lock(rwlock_t *lock) |
| 177 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 178 | __read_lock(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | } |
| 180 | EXPORT_SYMBOL(_read_lock); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 181 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 183 | #ifndef CONFIG_INLINE_SPIN_LOCK_IRQSAVE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock) |
| 185 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 186 | return __spin_lock_irqsave(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | } |
| 188 | EXPORT_SYMBOL(_spin_lock_irqsave); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 189 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 191 | #ifndef CONFIG_INLINE_SPIN_LOCK_IRQ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | void __lockfunc _spin_lock_irq(spinlock_t *lock) |
| 193 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 194 | __spin_lock_irq(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | } |
| 196 | EXPORT_SYMBOL(_spin_lock_irq); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 197 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 199 | #ifndef CONFIG_INLINE_SPIN_LOCK_BH |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | void __lockfunc _spin_lock_bh(spinlock_t *lock) |
| 201 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 202 | __spin_lock_bh(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | } |
| 204 | EXPORT_SYMBOL(_spin_lock_bh); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 205 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 207 | #ifndef CONFIG_INLINE_READ_LOCK_IRQSAVE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | unsigned long __lockfunc _read_lock_irqsave(rwlock_t *lock) |
| 209 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 210 | return __read_lock_irqsave(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | } |
| 212 | EXPORT_SYMBOL(_read_lock_irqsave); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 213 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 215 | #ifndef CONFIG_INLINE_READ_LOCK_IRQ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | void __lockfunc _read_lock_irq(rwlock_t *lock) |
| 217 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 218 | __read_lock_irq(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | } |
| 220 | EXPORT_SYMBOL(_read_lock_irq); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 221 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 223 | #ifndef CONFIG_INLINE_READ_LOCK_BH |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | void __lockfunc _read_lock_bh(rwlock_t *lock) |
| 225 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 226 | __read_lock_bh(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | } |
| 228 | EXPORT_SYMBOL(_read_lock_bh); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 229 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 231 | #ifndef CONFIG_INLINE_WRITE_LOCK_IRQSAVE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | unsigned long __lockfunc _write_lock_irqsave(rwlock_t *lock) |
| 233 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 234 | return __write_lock_irqsave(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | } |
| 236 | EXPORT_SYMBOL(_write_lock_irqsave); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 237 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 239 | #ifndef CONFIG_INLINE_WRITE_LOCK_IRQ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | void __lockfunc _write_lock_irq(rwlock_t *lock) |
| 241 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 242 | __write_lock_irq(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | } |
| 244 | EXPORT_SYMBOL(_write_lock_irq); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 245 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 247 | #ifndef CONFIG_INLINE_WRITE_LOCK_BH |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | void __lockfunc _write_lock_bh(rwlock_t *lock) |
| 249 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 250 | __write_lock_bh(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | } |
| 252 | EXPORT_SYMBOL(_write_lock_bh); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 253 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 255 | #ifndef CONFIG_INLINE_SPIN_LOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | void __lockfunc _spin_lock(spinlock_t *lock) |
| 257 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 258 | __spin_lock(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | EXPORT_SYMBOL(_spin_lock); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 261 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 263 | #ifndef CONFIG_INLINE_WRITE_LOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | void __lockfunc _write_lock(rwlock_t *lock) |
| 265 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 266 | __write_lock(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | EXPORT_SYMBOL(_write_lock); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 269 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 271 | #ifndef CONFIG_INLINE_SPIN_UNLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | void __lockfunc _spin_unlock(spinlock_t *lock) |
| 273 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 274 | __spin_unlock(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | } |
| 276 | EXPORT_SYMBOL(_spin_unlock); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 277 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 279 | #ifndef CONFIG_INLINE_WRITE_UNLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | void __lockfunc _write_unlock(rwlock_t *lock) |
| 281 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 282 | __write_unlock(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | } |
| 284 | EXPORT_SYMBOL(_write_unlock); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 285 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 287 | #ifndef CONFIG_INLINE_READ_UNLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | void __lockfunc _read_unlock(rwlock_t *lock) |
| 289 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 290 | __read_unlock(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | } |
| 292 | EXPORT_SYMBOL(_read_unlock); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 293 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 295 | #ifndef CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | void __lockfunc _spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) |
| 297 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 298 | __spin_unlock_irqrestore(lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | } |
| 300 | EXPORT_SYMBOL(_spin_unlock_irqrestore); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 301 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 303 | #ifndef CONFIG_INLINE_SPIN_UNLOCK_IRQ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | void __lockfunc _spin_unlock_irq(spinlock_t *lock) |
| 305 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 306 | __spin_unlock_irq(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | } |
| 308 | EXPORT_SYMBOL(_spin_unlock_irq); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 309 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 311 | #ifndef CONFIG_INLINE_SPIN_UNLOCK_BH |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | void __lockfunc _spin_unlock_bh(spinlock_t *lock) |
| 313 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 314 | __spin_unlock_bh(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | } |
| 316 | EXPORT_SYMBOL(_spin_unlock_bh); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 317 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 319 | #ifndef CONFIG_INLINE_READ_UNLOCK_IRQRESTORE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | void __lockfunc _read_unlock_irqrestore(rwlock_t *lock, unsigned long flags) |
| 321 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 322 | __read_unlock_irqrestore(lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | } |
| 324 | EXPORT_SYMBOL(_read_unlock_irqrestore); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 325 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 327 | #ifndef CONFIG_INLINE_READ_UNLOCK_IRQ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | void __lockfunc _read_unlock_irq(rwlock_t *lock) |
| 329 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 330 | __read_unlock_irq(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | } |
| 332 | EXPORT_SYMBOL(_read_unlock_irq); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 333 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 335 | #ifndef CONFIG_INLINE_READ_UNLOCK_BH |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | void __lockfunc _read_unlock_bh(rwlock_t *lock) |
| 337 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 338 | __read_unlock_bh(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | } |
| 340 | EXPORT_SYMBOL(_read_unlock_bh); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 341 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 343 | #ifndef CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | void __lockfunc _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags) |
| 345 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 346 | __write_unlock_irqrestore(lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | } |
| 348 | EXPORT_SYMBOL(_write_unlock_irqrestore); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 349 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 351 | #ifndef CONFIG_INLINE_WRITE_UNLOCK_IRQ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | void __lockfunc _write_unlock_irq(rwlock_t *lock) |
| 353 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 354 | __write_unlock_irq(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | } |
| 356 | EXPORT_SYMBOL(_write_unlock_irq); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 357 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 359 | #ifndef CONFIG_INLINE_WRITE_UNLOCK_BH |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | void __lockfunc _write_unlock_bh(rwlock_t *lock) |
| 361 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 362 | __write_unlock_bh(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | } |
| 364 | EXPORT_SYMBOL(_write_unlock_bh); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 365 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | |
Thomas Gleixner | 6beb000 | 2009-11-09 15:21:34 +0000 | [diff] [blame] | 367 | #ifndef CONFIG_INLINE_SPIN_TRYLOCK_BH |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | int __lockfunc _spin_trylock_bh(spinlock_t *lock) |
| 369 | { |
Heiko Carstens | 69d0ee7 | 2009-08-31 14:43:36 +0200 | [diff] [blame] | 370 | return __spin_trylock_bh(lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | } |
| 372 | EXPORT_SYMBOL(_spin_trylock_bh); |
Heiko Carstens | 892a7c6 | 2009-08-31 14:43:37 +0200 | [diff] [blame] | 373 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | |
Steven Rostedt | 0764d23 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 375 | notrace int in_lock_functions(unsigned long addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | { |
| 377 | /* Linker adds these: start and end of __lockfunc functions */ |
| 378 | extern char __lock_text_start[], __lock_text_end[]; |
| 379 | |
| 380 | return addr >= (unsigned long)__lock_text_start |
| 381 | && addr < (unsigned long)__lock_text_end; |
| 382 | } |
| 383 | EXPORT_SYMBOL(in_lock_functions); |