diff options
author | Paul Mundt <lethal@linux-sh.org> | 2011-01-13 01:06:28 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2011-01-13 01:06:28 -0500 |
commit | f43dc23d5ea91fca257be02138a255f02d98e806 (patch) | |
tree | b29722f6e965316e90ac97abf79923ced250dc21 /kernel/spinlock.c | |
parent | f8e53553f452dcbf67cb89c8cba63a1cd6eb4cc0 (diff) | |
parent | 4162cf64973df51fc885825bc9ca4d055891c49f (diff) |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6 into common/serial-rework
Conflicts:
arch/sh/kernel/cpu/sh2/setup-sh7619.c
arch/sh/kernel/cpu/sh2a/setup-mxg.c
arch/sh/kernel/cpu/sh2a/setup-sh7201.c
arch/sh/kernel/cpu/sh2a/setup-sh7203.c
arch/sh/kernel/cpu/sh2a/setup-sh7206.c
arch/sh/kernel/cpu/sh3/setup-sh7705.c
arch/sh/kernel/cpu/sh3/setup-sh770x.c
arch/sh/kernel/cpu/sh3/setup-sh7710.c
arch/sh/kernel/cpu/sh3/setup-sh7720.c
arch/sh/kernel/cpu/sh4/setup-sh4-202.c
arch/sh/kernel/cpu/sh4/setup-sh7750.c
arch/sh/kernel/cpu/sh4/setup-sh7760.c
arch/sh/kernel/cpu/sh4a/setup-sh7343.c
arch/sh/kernel/cpu/sh4a/setup-sh7366.c
arch/sh/kernel/cpu/sh4a/setup-sh7722.c
arch/sh/kernel/cpu/sh4a/setup-sh7723.c
arch/sh/kernel/cpu/sh4a/setup-sh7724.c
arch/sh/kernel/cpu/sh4a/setup-sh7763.c
arch/sh/kernel/cpu/sh4a/setup-sh7770.c
arch/sh/kernel/cpu/sh4a/setup-sh7780.c
arch/sh/kernel/cpu/sh4a/setup-sh7785.c
arch/sh/kernel/cpu/sh4a/setup-sh7786.c
arch/sh/kernel/cpu/sh4a/setup-shx3.c
arch/sh/kernel/cpu/sh5/setup-sh5.c
drivers/serial/sh-sci.c
drivers/serial/sh-sci.h
include/linux/serial_sci.h
Diffstat (limited to 'kernel/spinlock.c')
-rw-r--r-- | kernel/spinlock.c | 530 |
1 files changed, 233 insertions, 297 deletions
diff --git a/kernel/spinlock.c b/kernel/spinlock.c index 7932653c4ebd..be6517fb9c14 100644 --- a/kernel/spinlock.c +++ b/kernel/spinlock.c | |||
@@ -21,239 +21,72 @@ | |||
21 | #include <linux/debug_locks.h> | 21 | #include <linux/debug_locks.h> |
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | 23 | ||
24 | int __lockfunc _spin_trylock(spinlock_t *lock) | ||
25 | { | ||
26 | preempt_disable(); | ||
27 | if (_raw_spin_trylock(lock)) { | ||
28 | spin_acquire(&lock->dep_map, 0, 1, _RET_IP_); | ||
29 | return 1; | ||
30 | } | ||
31 | |||
32 | preempt_enable(); | ||
33 | return 0; | ||
34 | } | ||
35 | EXPORT_SYMBOL(_spin_trylock); | ||
36 | |||
37 | int __lockfunc _read_trylock(rwlock_t *lock) | ||
38 | { | ||
39 | preempt_disable(); | ||
40 | if (_raw_read_trylock(lock)) { | ||
41 | rwlock_acquire_read(&lock->dep_map, 0, 1, _RET_IP_); | ||
42 | return 1; | ||
43 | } | ||
44 | |||
45 | preempt_enable(); | ||
46 | return 0; | ||
47 | } | ||
48 | EXPORT_SYMBOL(_read_trylock); | ||
49 | |||
50 | int __lockfunc _write_trylock(rwlock_t *lock) | ||
51 | { | ||
52 | preempt_disable(); | ||
53 | if (_raw_write_trylock(lock)) { | ||
54 | rwlock_acquire(&lock->dep_map, 0, 1, _RET_IP_); | ||
55 | return 1; | ||
56 | } | ||
57 | |||
58 | preempt_enable(); | ||
59 | return 0; | ||
60 | } | ||
61 | EXPORT_SYMBOL(_write_trylock); | ||
62 | |||
63 | /* | 24 | /* |
64 | * If lockdep is enabled then we use the non-preemption spin-ops | 25 | * If lockdep is enabled then we use the non-preemption spin-ops |
65 | * even on CONFIG_PREEMPT, because lockdep assumes that interrupts are | 26 | * even on CONFIG_PREEMPT, because lockdep assumes that interrupts are |
66 | * not re-enabled during lock-acquire (which the preempt-spin-ops do): | 27 | * not re-enabled during lock-acquire (which the preempt-spin-ops do): |
67 | */ | 28 | */ |
68 | #if !defined(CONFIG_GENERIC_LOCKBREAK) || defined(CONFIG_DEBUG_LOCK_ALLOC) | 29 | #if !defined(CONFIG_GENERIC_LOCKBREAK) || defined(CONFIG_DEBUG_LOCK_ALLOC) |
69 | 30 | /* | |
70 | void __lockfunc _read_lock(rwlock_t *lock) | 31 | * The __lock_function inlines are taken from |
71 | { | 32 | * include/linux/spinlock_api_smp.h |
72 | preempt_disable(); | 33 | */ |
73 | rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_); | ||
74 | LOCK_CONTENDED(lock, _raw_read_trylock, _raw_read_lock); | ||
75 | } | ||
76 | EXPORT_SYMBOL(_read_lock); | ||
77 | |||
78 | unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock) | ||
79 | { | ||
80 | unsigned long flags; | ||
81 | |||
82 | local_irq_save(flags); | ||
83 | preempt_disable(); | ||
84 | spin_acquire(&lock->dep_map, 0, 0, _RET_IP_); | ||
85 | /* | ||
86 | * On lockdep we dont want the hand-coded irq-enable of | ||
87 | * _raw_spin_lock_flags() code, because lockdep assumes | ||
88 | * that interrupts are not re-enabled during lock-acquire: | ||
89 | */ | ||
90 | #ifdef CONFIG_LOCKDEP | ||
91 | LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock); | ||
92 | #else | 34 | #else |
93 | _raw_spin_lock_flags(lock, &flags); | 35 | #define raw_read_can_lock(l) read_can_lock(l) |
94 | #endif | 36 | #define raw_write_can_lock(l) write_can_lock(l) |
95 | return flags; | ||
96 | } | ||
97 | EXPORT_SYMBOL(_spin_lock_irqsave); | ||
98 | |||
99 | void __lockfunc _spin_lock_irq(spinlock_t *lock) | ||
100 | { | ||
101 | local_irq_disable(); | ||
102 | preempt_disable(); | ||
103 | spin_acquire(&lock->dep_map, 0, 0, _RET_IP_); | ||
104 | LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock); | ||
105 | } | ||
106 | EXPORT_SYMBOL(_spin_lock_irq); | ||
107 | |||
108 | void __lockfunc _spin_lock_bh(spinlock_t *lock) | ||
109 | { | ||
110 | local_bh_disable(); | ||
111 | preempt_disable(); | ||
112 | spin_acquire(&lock->dep_map, 0, 0, _RET_IP_); | ||
113 | LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock); | ||
114 | } | ||
115 | EXPORT_SYMBOL(_spin_lock_bh); | ||
116 | |||
117 | unsigned long __lockfunc _read_lock_irqsave(rwlock_t *lock) | ||
118 | { | ||
119 | unsigned long flags; | ||
120 | |||
121 | local_irq_save(flags); | ||
122 | preempt_disable(); | ||
123 | rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_); | ||
124 | LOCK_CONTENDED_FLAGS(lock, _raw_read_trylock, _raw_read_lock, | ||
125 | _raw_read_lock_flags, &flags); | ||
126 | return flags; | ||
127 | } | ||
128 | EXPORT_SYMBOL(_read_lock_irqsave); | ||
129 | |||
130 | void __lockfunc _read_lock_irq(rwlock_t *lock) | ||
131 | { | ||
132 | local_irq_disable(); | ||
133 | preempt_disable(); | ||
134 | rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_); | ||
135 | LOCK_CONTENDED(lock, _raw_read_trylock, _raw_read_lock); | ||
136 | } | ||
137 | EXPORT_SYMBOL(_read_lock_irq); | ||
138 | |||
139 | void __lockfunc _read_lock_bh(rwlock_t *lock) | ||
140 | { | ||
141 | local_bh_disable(); | ||
142 | preempt_disable(); | ||
143 | rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_); | ||
144 | LOCK_CONTENDED(lock, _raw_read_trylock, _raw_read_lock); | ||
145 | } | ||
146 | EXPORT_SYMBOL(_read_lock_bh); | ||
147 | |||
148 | unsigned long __lockfunc _write_lock_irqsave(rwlock_t *lock) | ||
149 | { | ||
150 | unsigned long flags; | ||
151 | |||
152 | local_irq_save(flags); | ||
153 | preempt_disable(); | ||
154 | rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_); | ||
155 | LOCK_CONTENDED_FLAGS(lock, _raw_write_trylock, _raw_write_lock, | ||
156 | _raw_write_lock_flags, &flags); | ||
157 | return flags; | ||
158 | } | ||
159 | EXPORT_SYMBOL(_write_lock_irqsave); | ||
160 | |||
161 | void __lockfunc _write_lock_irq(rwlock_t *lock) | ||
162 | { | ||
163 | local_irq_disable(); | ||
164 | preempt_disable(); | ||
165 | rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_); | ||
166 | LOCK_CONTENDED(lock, _raw_write_trylock, _raw_write_lock); | ||
167 | } | ||
168 | EXPORT_SYMBOL(_write_lock_irq); | ||
169 | |||
170 | void __lockfunc _write_lock_bh(rwlock_t *lock) | ||
171 | { | ||
172 | local_bh_disable(); | ||
173 | preempt_disable(); | ||
174 | rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_); | ||
175 | LOCK_CONTENDED(lock, _raw_write_trylock, _raw_write_lock); | ||
176 | } | ||
177 | EXPORT_SYMBOL(_write_lock_bh); | ||
178 | |||
179 | void __lockfunc _spin_lock(spinlock_t *lock) | ||
180 | { | ||
181 | preempt_disable(); | ||
182 | spin_acquire(&lock->dep_map, 0, 0, _RET_IP_); | ||
183 | LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock); | ||
184 | } | ||
185 | |||
186 | EXPORT_SYMBOL(_spin_lock); | ||
187 | |||
188 | void __lockfunc _write_lock(rwlock_t *lock) | ||
189 | { | ||
190 | preempt_disable(); | ||
191 | rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_); | ||
192 | LOCK_CONTENDED(lock, _raw_write_trylock, _raw_write_lock); | ||
193 | } | ||
194 | |||
195 | EXPORT_SYMBOL(_write_lock); | ||
196 | |||
197 | #else /* CONFIG_PREEMPT: */ | ||
198 | |||
199 | /* | 37 | /* |
38 | * We build the __lock_function inlines here. They are too large for | ||
39 | * inlining all over the place, but here is only one user per function | ||
40 | * which embedds them into the calling _lock_function below. | ||
41 | * | ||
200 | * This could be a long-held lock. We both prepare to spin for a long | 42 | * This could be a long-held lock. We both prepare to spin for a long |
201 | * time (making _this_ CPU preemptable if possible), and we also signal | 43 | * time (making _this_ CPU preemptable if possible), and we also signal |
202 | * towards that other CPU that it should break the lock ASAP. | 44 | * towards that other CPU that it should break the lock ASAP. |
203 | * | ||
204 | * (We do this in a function because inlining it would be excessive.) | ||
205 | */ | 45 | */ |
206 | |||
207 | #define BUILD_LOCK_OPS(op, locktype) \ | 46 | #define BUILD_LOCK_OPS(op, locktype) \ |
208 | void __lockfunc _##op##_lock(locktype##_t *lock) \ | 47 | void __lockfunc __raw_##op##_lock(locktype##_t *lock) \ |
209 | { \ | 48 | { \ |
210 | for (;;) { \ | 49 | for (;;) { \ |
211 | preempt_disable(); \ | 50 | preempt_disable(); \ |
212 | if (likely(_raw_##op##_trylock(lock))) \ | 51 | if (likely(do_raw_##op##_trylock(lock))) \ |
213 | break; \ | 52 | break; \ |
214 | preempt_enable(); \ | 53 | preempt_enable(); \ |
215 | \ | 54 | \ |
216 | if (!(lock)->break_lock) \ | 55 | if (!(lock)->break_lock) \ |
217 | (lock)->break_lock = 1; \ | 56 | (lock)->break_lock = 1; \ |
218 | while (!op##_can_lock(lock) && (lock)->break_lock) \ | 57 | while (!raw_##op##_can_lock(lock) && (lock)->break_lock)\ |
219 | _raw_##op##_relax(&lock->raw_lock); \ | 58 | arch_##op##_relax(&lock->raw_lock); \ |
220 | } \ | 59 | } \ |
221 | (lock)->break_lock = 0; \ | 60 | (lock)->break_lock = 0; \ |
222 | } \ | 61 | } \ |
223 | \ | 62 | \ |
224 | EXPORT_SYMBOL(_##op##_lock); \ | 63 | unsigned long __lockfunc __raw_##op##_lock_irqsave(locktype##_t *lock) \ |
225 | \ | ||
226 | unsigned long __lockfunc _##op##_lock_irqsave(locktype##_t *lock) \ | ||
227 | { \ | 64 | { \ |
228 | unsigned long flags; \ | 65 | unsigned long flags; \ |
229 | \ | 66 | \ |
230 | for (;;) { \ | 67 | for (;;) { \ |
231 | preempt_disable(); \ | 68 | preempt_disable(); \ |
232 | local_irq_save(flags); \ | 69 | local_irq_save(flags); \ |
233 | if (likely(_raw_##op##_trylock(lock))) \ | 70 | if (likely(do_raw_##op##_trylock(lock))) \ |
234 | break; \ | 71 | break; \ |
235 | local_irq_restore(flags); \ | 72 | local_irq_restore(flags); \ |
236 | preempt_enable(); \ | 73 | preempt_enable(); \ |
237 | \ | 74 | \ |
238 | if (!(lock)->break_lock) \ | 75 | if (!(lock)->break_lock) \ |
239 | (lock)->break_lock = 1; \ | 76 | (lock)->break_lock = 1; \ |
240 | while (!op##_can_lock(lock) && (lock)->break_lock) \ | 77 | while (!raw_##op##_can_lock(lock) && (lock)->break_lock)\ |
241 | _raw_##op##_relax(&lock->raw_lock); \ | 78 | arch_##op##_relax(&lock->raw_lock); \ |
242 | } \ | 79 | } \ |
243 | (lock)->break_lock = 0; \ | 80 | (lock)->break_lock = 0; \ |
244 | return flags; \ | 81 | return flags; \ |
245 | } \ | 82 | } \ |
246 | \ | 83 | \ |
247 | EXPORT_SYMBOL(_##op##_lock_irqsave); \ | 84 | void __lockfunc __raw_##op##_lock_irq(locktype##_t *lock) \ |
248 | \ | ||
249 | void __lockfunc _##op##_lock_irq(locktype##_t *lock) \ | ||
250 | { \ | 85 | { \ |
251 | _##op##_lock_irqsave(lock); \ | 86 | _raw_##op##_lock_irqsave(lock); \ |
252 | } \ | 87 | } \ |
253 | \ | 88 | \ |
254 | EXPORT_SYMBOL(_##op##_lock_irq); \ | 89 | void __lockfunc __raw_##op##_lock_bh(locktype##_t *lock) \ |
255 | \ | ||
256 | void __lockfunc _##op##_lock_bh(locktype##_t *lock) \ | ||
257 | { \ | 90 | { \ |
258 | unsigned long flags; \ | 91 | unsigned long flags; \ |
259 | \ | 92 | \ |
@@ -262,181 +95,284 @@ void __lockfunc _##op##_lock_bh(locktype##_t *lock) \ | |||
262 | /* irq-disabling. We use the generic preemption-aware */ \ | 95 | /* irq-disabling. We use the generic preemption-aware */ \ |
263 | /* function: */ \ | 96 | /* function: */ \ |
264 | /**/ \ | 97 | /**/ \ |
265 | flags = _##op##_lock_irqsave(lock); \ | 98 | flags = _raw_##op##_lock_irqsave(lock); \ |
266 | local_bh_disable(); \ | 99 | local_bh_disable(); \ |
267 | local_irq_restore(flags); \ | 100 | local_irq_restore(flags); \ |
268 | } \ | 101 | } \ |
269 | \ | ||
270 | EXPORT_SYMBOL(_##op##_lock_bh) | ||
271 | 102 | ||
272 | /* | 103 | /* |
273 | * Build preemption-friendly versions of the following | 104 | * Build preemption-friendly versions of the following |
274 | * lock-spinning functions: | 105 | * lock-spinning functions: |
275 | * | 106 | * |
276 | * _[spin|read|write]_lock() | 107 | * __[spin|read|write]_lock() |
277 | * _[spin|read|write]_lock_irq() | 108 | * __[spin|read|write]_lock_irq() |
278 | * _[spin|read|write]_lock_irqsave() | 109 | * __[spin|read|write]_lock_irqsave() |
279 | * _[spin|read|write]_lock_bh() | 110 | * __[spin|read|write]_lock_bh() |
280 | */ | 111 | */ |
281 | BUILD_LOCK_OPS(spin, spinlock); | 112 | BUILD_LOCK_OPS(spin, raw_spinlock); |
282 | BUILD_LOCK_OPS(read, rwlock); | 113 | BUILD_LOCK_OPS(read, rwlock); |
283 | BUILD_LOCK_OPS(write, rwlock); | 114 | BUILD_LOCK_OPS(write, rwlock); |
284 | 115 | ||
285 | #endif /* CONFIG_PREEMPT */ | 116 | #endif |
286 | 117 | ||
287 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 118 | #ifndef CONFIG_INLINE_SPIN_TRYLOCK |
119 | int __lockfunc _raw_spin_trylock(raw_spinlock_t *lock) | ||
120 | { | ||
121 | return __raw_spin_trylock(lock); | ||
122 | } | ||
123 | EXPORT_SYMBOL(_raw_spin_trylock); | ||
124 | #endif | ||
288 | 125 | ||
289 | void __lockfunc _spin_lock_nested(spinlock_t *lock, int subclass) | 126 | #ifndef CONFIG_INLINE_SPIN_TRYLOCK_BH |
127 | int __lockfunc _raw_spin_trylock_bh(raw_spinlock_t *lock) | ||
290 | { | 128 | { |
291 | preempt_disable(); | 129 | return __raw_spin_trylock_bh(lock); |
292 | spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_); | ||
293 | LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock); | ||
294 | } | 130 | } |
295 | EXPORT_SYMBOL(_spin_lock_nested); | 131 | EXPORT_SYMBOL(_raw_spin_trylock_bh); |
132 | #endif | ||
296 | 133 | ||
297 | unsigned long __lockfunc _spin_lock_irqsave_nested(spinlock_t *lock, int subclass) | 134 | #ifndef CONFIG_INLINE_SPIN_LOCK |
135 | void __lockfunc _raw_spin_lock(raw_spinlock_t *lock) | ||
298 | { | 136 | { |
299 | unsigned long flags; | 137 | __raw_spin_lock(lock); |
138 | } | ||
139 | EXPORT_SYMBOL(_raw_spin_lock); | ||
140 | #endif | ||
300 | 141 | ||
301 | local_irq_save(flags); | 142 | #ifndef CONFIG_INLINE_SPIN_LOCK_IRQSAVE |
302 | preempt_disable(); | 143 | unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t *lock) |
303 | spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_); | 144 | { |
304 | LOCK_CONTENDED_FLAGS(lock, _raw_spin_trylock, _raw_spin_lock, | 145 | return __raw_spin_lock_irqsave(lock); |
305 | _raw_spin_lock_flags, &flags); | ||
306 | return flags; | ||
307 | } | 146 | } |
308 | EXPORT_SYMBOL(_spin_lock_irqsave_nested); | 147 | EXPORT_SYMBOL(_raw_spin_lock_irqsave); |
148 | #endif | ||
309 | 149 | ||
310 | void __lockfunc _spin_lock_nest_lock(spinlock_t *lock, | 150 | #ifndef CONFIG_INLINE_SPIN_LOCK_IRQ |
311 | struct lockdep_map *nest_lock) | 151 | void __lockfunc _raw_spin_lock_irq(raw_spinlock_t *lock) |
312 | { | 152 | { |
313 | preempt_disable(); | 153 | __raw_spin_lock_irq(lock); |
314 | spin_acquire_nest(&lock->dep_map, 0, 0, nest_lock, _RET_IP_); | 154 | } |
315 | LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock); | 155 | EXPORT_SYMBOL(_raw_spin_lock_irq); |
156 | #endif | ||
157 | |||
158 | #ifndef CONFIG_INLINE_SPIN_LOCK_BH | ||
159 | void __lockfunc _raw_spin_lock_bh(raw_spinlock_t *lock) | ||
160 | { | ||
161 | __raw_spin_lock_bh(lock); | ||
162 | } | ||
163 | EXPORT_SYMBOL(_raw_spin_lock_bh); | ||
164 | #endif | ||
165 | |||
166 | #ifndef CONFIG_INLINE_SPIN_UNLOCK | ||
167 | void __lockfunc _raw_spin_unlock(raw_spinlock_t *lock) | ||
168 | { | ||
169 | __raw_spin_unlock(lock); | ||
316 | } | 170 | } |
317 | EXPORT_SYMBOL(_spin_lock_nest_lock); | 171 | EXPORT_SYMBOL(_raw_spin_unlock); |
172 | #endif | ||
318 | 173 | ||
174 | #ifndef CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE | ||
175 | void __lockfunc _raw_spin_unlock_irqrestore(raw_spinlock_t *lock, unsigned long flags) | ||
176 | { | ||
177 | __raw_spin_unlock_irqrestore(lock, flags); | ||
178 | } | ||
179 | EXPORT_SYMBOL(_raw_spin_unlock_irqrestore); | ||
319 | #endif | 180 | #endif |
320 | 181 | ||
321 | void __lockfunc _spin_unlock(spinlock_t *lock) | 182 | #ifndef CONFIG_INLINE_SPIN_UNLOCK_IRQ |
183 | void __lockfunc _raw_spin_unlock_irq(raw_spinlock_t *lock) | ||
322 | { | 184 | { |
323 | spin_release(&lock->dep_map, 1, _RET_IP_); | 185 | __raw_spin_unlock_irq(lock); |
324 | _raw_spin_unlock(lock); | ||
325 | preempt_enable(); | ||
326 | } | 186 | } |
327 | EXPORT_SYMBOL(_spin_unlock); | 187 | EXPORT_SYMBOL(_raw_spin_unlock_irq); |
188 | #endif | ||
328 | 189 | ||
329 | void __lockfunc _write_unlock(rwlock_t *lock) | 190 | #ifndef CONFIG_INLINE_SPIN_UNLOCK_BH |
191 | void __lockfunc _raw_spin_unlock_bh(raw_spinlock_t *lock) | ||
330 | { | 192 | { |
331 | rwlock_release(&lock->dep_map, 1, _RET_IP_); | 193 | __raw_spin_unlock_bh(lock); |
332 | _raw_write_unlock(lock); | ||
333 | preempt_enable(); | ||
334 | } | 194 | } |
335 | EXPORT_SYMBOL(_write_unlock); | 195 | EXPORT_SYMBOL(_raw_spin_unlock_bh); |
196 | #endif | ||
336 | 197 | ||
337 | void __lockfunc _read_unlock(rwlock_t *lock) | 198 | #ifndef CONFIG_INLINE_READ_TRYLOCK |
199 | int __lockfunc _raw_read_trylock(rwlock_t *lock) | ||
338 | { | 200 | { |
339 | rwlock_release(&lock->dep_map, 1, _RET_IP_); | 201 | return __raw_read_trylock(lock); |
340 | _raw_read_unlock(lock); | ||
341 | preempt_enable(); | ||
342 | } | 202 | } |
343 | EXPORT_SYMBOL(_read_unlock); | 203 | EXPORT_SYMBOL(_raw_read_trylock); |
204 | #endif | ||
344 | 205 | ||
345 | void __lockfunc _spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) | 206 | #ifndef CONFIG_INLINE_READ_LOCK |
207 | void __lockfunc _raw_read_lock(rwlock_t *lock) | ||
346 | { | 208 | { |
347 | spin_release(&lock->dep_map, 1, _RET_IP_); | 209 | __raw_read_lock(lock); |
348 | _raw_spin_unlock(lock); | ||
349 | local_irq_restore(flags); | ||
350 | preempt_enable(); | ||
351 | } | 210 | } |
352 | EXPORT_SYMBOL(_spin_unlock_irqrestore); | 211 | EXPORT_SYMBOL(_raw_read_lock); |
212 | #endif | ||
353 | 213 | ||
354 | void __lockfunc _spin_unlock_irq(spinlock_t *lock) | 214 | #ifndef CONFIG_INLINE_READ_LOCK_IRQSAVE |
215 | unsigned long __lockfunc _raw_read_lock_irqsave(rwlock_t *lock) | ||
355 | { | 216 | { |
356 | spin_release(&lock->dep_map, 1, _RET_IP_); | 217 | return __raw_read_lock_irqsave(lock); |
357 | _raw_spin_unlock(lock); | ||
358 | local_irq_enable(); | ||
359 | preempt_enable(); | ||
360 | } | 218 | } |
361 | EXPORT_SYMBOL(_spin_unlock_irq); | 219 | EXPORT_SYMBOL(_raw_read_lock_irqsave); |
220 | #endif | ||
362 | 221 | ||
363 | void __lockfunc _spin_unlock_bh(spinlock_t *lock) | 222 | #ifndef CONFIG_INLINE_READ_LOCK_IRQ |
223 | void __lockfunc _raw_read_lock_irq(rwlock_t *lock) | ||
364 | { | 224 | { |
365 | spin_release(&lock->dep_map, 1, _RET_IP_); | 225 | __raw_read_lock_irq(lock); |
366 | _raw_spin_unlock(lock); | ||
367 | preempt_enable_no_resched(); | ||
368 | local_bh_enable_ip((unsigned long)__builtin_return_address(0)); | ||
369 | } | 226 | } |
370 | EXPORT_SYMBOL(_spin_unlock_bh); | 227 | EXPORT_SYMBOL(_raw_read_lock_irq); |
228 | #endif | ||
371 | 229 | ||
372 | void __lockfunc _read_unlock_irqrestore(rwlock_t *lock, unsigned long flags) | 230 | #ifndef CONFIG_INLINE_READ_LOCK_BH |
231 | void __lockfunc _raw_read_lock_bh(rwlock_t *lock) | ||
373 | { | 232 | { |
374 | rwlock_release(&lock->dep_map, 1, _RET_IP_); | 233 | __raw_read_lock_bh(lock); |
375 | _raw_read_unlock(lock); | ||
376 | local_irq_restore(flags); | ||
377 | preempt_enable(); | ||
378 | } | 234 | } |
379 | EXPORT_SYMBOL(_read_unlock_irqrestore); | 235 | EXPORT_SYMBOL(_raw_read_lock_bh); |
236 | #endif | ||
380 | 237 | ||
381 | void __lockfunc _read_unlock_irq(rwlock_t *lock) | 238 | #ifndef CONFIG_INLINE_READ_UNLOCK |
239 | void __lockfunc _raw_read_unlock(rwlock_t *lock) | ||
382 | { | 240 | { |
383 | rwlock_release(&lock->dep_map, 1, _RET_IP_); | 241 | __raw_read_unlock(lock); |
384 | _raw_read_unlock(lock); | ||
385 | local_irq_enable(); | ||
386 | preempt_enable(); | ||
387 | } | 242 | } |
388 | EXPORT_SYMBOL(_read_unlock_irq); | 243 | EXPORT_SYMBOL(_raw_read_unlock); |
244 | #endif | ||
389 | 245 | ||
390 | void __lockfunc _read_unlock_bh(rwlock_t *lock) | 246 | #ifndef CONFIG_INLINE_READ_UNLOCK_IRQRESTORE |
247 | void __lockfunc _raw_read_unlock_irqrestore(rwlock_t *lock, unsigned long flags) | ||
391 | { | 248 | { |
392 | rwlock_release(&lock->dep_map, 1, _RET_IP_); | 249 | __raw_read_unlock_irqrestore(lock, flags); |
393 | _raw_read_unlock(lock); | ||
394 | preempt_enable_no_resched(); | ||
395 | local_bh_enable_ip((unsigned long)__builtin_return_address(0)); | ||
396 | } | 250 | } |
397 | EXPORT_SYMBOL(_read_unlock_bh); | 251 | EXPORT_SYMBOL(_raw_read_unlock_irqrestore); |
252 | #endif | ||
398 | 253 | ||
399 | void __lockfunc _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags) | 254 | #ifndef CONFIG_INLINE_READ_UNLOCK_IRQ |
255 | void __lockfunc _raw_read_unlock_irq(rwlock_t *lock) | ||
400 | { | 256 | { |
401 | rwlock_release(&lock->dep_map, 1, _RET_IP_); | 257 | __raw_read_unlock_irq(lock); |
402 | _raw_write_unlock(lock); | ||
403 | local_irq_restore(flags); | ||
404 | preempt_enable(); | ||
405 | } | 258 | } |
406 | EXPORT_SYMBOL(_write_unlock_irqrestore); | 259 | EXPORT_SYMBOL(_raw_read_unlock_irq); |
260 | #endif | ||
407 | 261 | ||
408 | void __lockfunc _write_unlock_irq(rwlock_t *lock) | 262 | #ifndef CONFIG_INLINE_READ_UNLOCK_BH |
263 | void __lockfunc _raw_read_unlock_bh(rwlock_t *lock) | ||
409 | { | 264 | { |
410 | rwlock_release(&lock->dep_map, 1, _RET_IP_); | 265 | __raw_read_unlock_bh(lock); |
411 | _raw_write_unlock(lock); | ||
412 | local_irq_enable(); | ||
413 | preempt_enable(); | ||
414 | } | 266 | } |
415 | EXPORT_SYMBOL(_write_unlock_irq); | 267 | EXPORT_SYMBOL(_raw_read_unlock_bh); |
268 | #endif | ||
416 | 269 | ||
417 | void __lockfunc _write_unlock_bh(rwlock_t *lock) | 270 | #ifndef CONFIG_INLINE_WRITE_TRYLOCK |
271 | int __lockfunc _raw_write_trylock(rwlock_t *lock) | ||
418 | { | 272 | { |
419 | rwlock_release(&lock->dep_map, 1, _RET_IP_); | 273 | return __raw_write_trylock(lock); |
420 | _raw_write_unlock(lock); | ||
421 | preempt_enable_no_resched(); | ||
422 | local_bh_enable_ip((unsigned long)__builtin_return_address(0)); | ||
423 | } | 274 | } |
424 | EXPORT_SYMBOL(_write_unlock_bh); | 275 | EXPORT_SYMBOL(_raw_write_trylock); |
276 | #endif | ||
425 | 277 | ||
426 | int __lockfunc _spin_trylock_bh(spinlock_t *lock) | 278 | #ifndef CONFIG_INLINE_WRITE_LOCK |
279 | void __lockfunc _raw_write_lock(rwlock_t *lock) | ||
427 | { | 280 | { |
428 | local_bh_disable(); | 281 | __raw_write_lock(lock); |
282 | } | ||
283 | EXPORT_SYMBOL(_raw_write_lock); | ||
284 | #endif | ||
285 | |||
286 | #ifndef CONFIG_INLINE_WRITE_LOCK_IRQSAVE | ||
287 | unsigned long __lockfunc _raw_write_lock_irqsave(rwlock_t *lock) | ||
288 | { | ||
289 | return __raw_write_lock_irqsave(lock); | ||
290 | } | ||
291 | EXPORT_SYMBOL(_raw_write_lock_irqsave); | ||
292 | #endif | ||
293 | |||
294 | #ifndef CONFIG_INLINE_WRITE_LOCK_IRQ | ||
295 | void __lockfunc _raw_write_lock_irq(rwlock_t *lock) | ||
296 | { | ||
297 | __raw_write_lock_irq(lock); | ||
298 | } | ||
299 | EXPORT_SYMBOL(_raw_write_lock_irq); | ||
300 | #endif | ||
301 | |||
302 | #ifndef CONFIG_INLINE_WRITE_LOCK_BH | ||
303 | void __lockfunc _raw_write_lock_bh(rwlock_t *lock) | ||
304 | { | ||
305 | __raw_write_lock_bh(lock); | ||
306 | } | ||
307 | EXPORT_SYMBOL(_raw_write_lock_bh); | ||
308 | #endif | ||
309 | |||
310 | #ifndef CONFIG_INLINE_WRITE_UNLOCK | ||
311 | void __lockfunc _raw_write_unlock(rwlock_t *lock) | ||
312 | { | ||
313 | __raw_write_unlock(lock); | ||
314 | } | ||
315 | EXPORT_SYMBOL(_raw_write_unlock); | ||
316 | #endif | ||
317 | |||
318 | #ifndef CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE | ||
319 | void __lockfunc _raw_write_unlock_irqrestore(rwlock_t *lock, unsigned long flags) | ||
320 | { | ||
321 | __raw_write_unlock_irqrestore(lock, flags); | ||
322 | } | ||
323 | EXPORT_SYMBOL(_raw_write_unlock_irqrestore); | ||
324 | #endif | ||
325 | |||
326 | #ifndef CONFIG_INLINE_WRITE_UNLOCK_IRQ | ||
327 | void __lockfunc _raw_write_unlock_irq(rwlock_t *lock) | ||
328 | { | ||
329 | __raw_write_unlock_irq(lock); | ||
330 | } | ||
331 | EXPORT_SYMBOL(_raw_write_unlock_irq); | ||
332 | #endif | ||
333 | |||
334 | #ifndef CONFIG_INLINE_WRITE_UNLOCK_BH | ||
335 | void __lockfunc _raw_write_unlock_bh(rwlock_t *lock) | ||
336 | { | ||
337 | __raw_write_unlock_bh(lock); | ||
338 | } | ||
339 | EXPORT_SYMBOL(_raw_write_unlock_bh); | ||
340 | #endif | ||
341 | |||
342 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
343 | |||
344 | void __lockfunc _raw_spin_lock_nested(raw_spinlock_t *lock, int subclass) | ||
345 | { | ||
346 | preempt_disable(); | ||
347 | spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_); | ||
348 | LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock); | ||
349 | } | ||
350 | EXPORT_SYMBOL(_raw_spin_lock_nested); | ||
351 | |||
352 | unsigned long __lockfunc _raw_spin_lock_irqsave_nested(raw_spinlock_t *lock, | ||
353 | int subclass) | ||
354 | { | ||
355 | unsigned long flags; | ||
356 | |||
357 | local_irq_save(flags); | ||
429 | preempt_disable(); | 358 | preempt_disable(); |
430 | if (_raw_spin_trylock(lock)) { | 359 | spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_); |
431 | spin_acquire(&lock->dep_map, 0, 1, _RET_IP_); | 360 | LOCK_CONTENDED_FLAGS(lock, do_raw_spin_trylock, do_raw_spin_lock, |
432 | return 1; | 361 | do_raw_spin_lock_flags, &flags); |
433 | } | 362 | return flags; |
363 | } | ||
364 | EXPORT_SYMBOL(_raw_spin_lock_irqsave_nested); | ||
434 | 365 | ||
435 | preempt_enable_no_resched(); | 366 | void __lockfunc _raw_spin_lock_nest_lock(raw_spinlock_t *lock, |
436 | local_bh_enable_ip((unsigned long)__builtin_return_address(0)); | 367 | struct lockdep_map *nest_lock) |
437 | return 0; | 368 | { |
369 | preempt_disable(); | ||
370 | spin_acquire_nest(&lock->dep_map, 0, 0, nest_lock, _RET_IP_); | ||
371 | LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock); | ||
438 | } | 372 | } |
439 | EXPORT_SYMBOL(_spin_trylock_bh); | 373 | EXPORT_SYMBOL(_raw_spin_lock_nest_lock); |
374 | |||
375 | #endif | ||
440 | 376 | ||
441 | notrace int in_lock_functions(unsigned long addr) | 377 | notrace int in_lock_functions(unsigned long addr) |
442 | { | 378 | { |