diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/spinlock.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/kernel/spinlock.c b/kernel/spinlock.c index 0375fcd5921d..d1b810782bc4 100644 --- a/kernel/spinlock.c +++ b/kernel/spinlock.c | |||
@@ -179,16 +179,16 @@ EXPORT_SYMBOL(_write_lock); | |||
179 | #define BUILD_LOCK_OPS(op, locktype) \ | 179 | #define BUILD_LOCK_OPS(op, locktype) \ |
180 | void __lockfunc _##op##_lock(locktype##_t *lock) \ | 180 | void __lockfunc _##op##_lock(locktype##_t *lock) \ |
181 | { \ | 181 | { \ |
182 | preempt_disable(); \ | ||
183 | for (;;) { \ | 182 | for (;;) { \ |
183 | preempt_disable(); \ | ||
184 | if (likely(_raw_##op##_trylock(lock))) \ | 184 | if (likely(_raw_##op##_trylock(lock))) \ |
185 | break; \ | 185 | break; \ |
186 | preempt_enable(); \ | 186 | preempt_enable(); \ |
187 | \ | ||
187 | if (!(lock)->break_lock) \ | 188 | if (!(lock)->break_lock) \ |
188 | (lock)->break_lock = 1; \ | 189 | (lock)->break_lock = 1; \ |
189 | while (!op##_can_lock(lock) && (lock)->break_lock) \ | 190 | while (!op##_can_lock(lock) && (lock)->break_lock) \ |
190 | cpu_relax(); \ | 191 | cpu_relax(); \ |
191 | preempt_disable(); \ | ||
192 | } \ | 192 | } \ |
193 | (lock)->break_lock = 0; \ | 193 | (lock)->break_lock = 0; \ |
194 | } \ | 194 | } \ |
@@ -199,19 +199,18 @@ unsigned long __lockfunc _##op##_lock_irqsave(locktype##_t *lock) \ | |||
199 | { \ | 199 | { \ |
200 | unsigned long flags; \ | 200 | unsigned long flags; \ |
201 | \ | 201 | \ |
202 | preempt_disable(); \ | ||
203 | for (;;) { \ | 202 | for (;;) { \ |
203 | preempt_disable(); \ | ||
204 | local_irq_save(flags); \ | 204 | local_irq_save(flags); \ |
205 | if (likely(_raw_##op##_trylock(lock))) \ | 205 | if (likely(_raw_##op##_trylock(lock))) \ |
206 | break; \ | 206 | break; \ |
207 | local_irq_restore(flags); \ | 207 | local_irq_restore(flags); \ |
208 | \ | ||
209 | preempt_enable(); \ | 208 | preempt_enable(); \ |
209 | \ | ||
210 | if (!(lock)->break_lock) \ | 210 | if (!(lock)->break_lock) \ |
211 | (lock)->break_lock = 1; \ | 211 | (lock)->break_lock = 1; \ |
212 | while (!op##_can_lock(lock) && (lock)->break_lock) \ | 212 | while (!op##_can_lock(lock) && (lock)->break_lock) \ |
213 | cpu_relax(); \ | 213 | cpu_relax(); \ |
214 | preempt_disable(); \ | ||
215 | } \ | 214 | } \ |
216 | (lock)->break_lock = 0; \ | 215 | (lock)->break_lock = 0; \ |
217 | return flags; \ | 216 | return flags; \ |