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