diff options
Diffstat (limited to 'include/asm-s390/spinlock.h')
-rw-r--r-- | include/asm-s390/spinlock.h | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/include/asm-s390/spinlock.h b/include/asm-s390/spinlock.h index 3fd43826fd0b..df84ae96915f 100644 --- a/include/asm-s390/spinlock.h +++ b/include/asm-s390/spinlock.h | |||
@@ -53,44 +53,48 @@ _raw_compare_and_swap(volatile unsigned int *lock, | |||
53 | */ | 53 | */ |
54 | 54 | ||
55 | #define __raw_spin_is_locked(x) ((x)->owner_cpu != 0) | 55 | #define __raw_spin_is_locked(x) ((x)->owner_cpu != 0) |
56 | #define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock) | ||
57 | #define __raw_spin_unlock_wait(lock) \ | 56 | #define __raw_spin_unlock_wait(lock) \ |
58 | do { while (__raw_spin_is_locked(lock)) \ | 57 | do { while (__raw_spin_is_locked(lock)) \ |
59 | _raw_spin_relax(lock); } while (0) | 58 | _raw_spin_relax(lock); } while (0) |
60 | 59 | ||
61 | extern void _raw_spin_lock_wait(raw_spinlock_t *, unsigned int pc); | 60 | extern void _raw_spin_lock_wait(raw_spinlock_t *); |
62 | extern int _raw_spin_trylock_retry(raw_spinlock_t *, unsigned int pc); | 61 | extern void _raw_spin_lock_wait_flags(raw_spinlock_t *, unsigned long flags); |
62 | extern int _raw_spin_trylock_retry(raw_spinlock_t *); | ||
63 | extern void _raw_spin_relax(raw_spinlock_t *lock); | 63 | extern void _raw_spin_relax(raw_spinlock_t *lock); |
64 | 64 | ||
65 | static inline void __raw_spin_lock(raw_spinlock_t *lp) | 65 | static inline void __raw_spin_lock(raw_spinlock_t *lp) |
66 | { | 66 | { |
67 | unsigned long pc = 1 | (unsigned long) __builtin_return_address(0); | ||
68 | int old; | 67 | int old; |
69 | 68 | ||
70 | old = _raw_compare_and_swap(&lp->owner_cpu, 0, ~smp_processor_id()); | 69 | old = _raw_compare_and_swap(&lp->owner_cpu, 0, ~smp_processor_id()); |
71 | if (likely(old == 0)) { | 70 | if (likely(old == 0)) |
72 | lp->owner_pc = pc; | ||
73 | return; | 71 | return; |
74 | } | 72 | _raw_spin_lock_wait(lp); |
75 | _raw_spin_lock_wait(lp, pc); | 73 | } |
74 | |||
75 | static inline void __raw_spin_lock_flags(raw_spinlock_t *lp, | ||
76 | unsigned long flags) | ||
77 | { | ||
78 | int old; | ||
79 | |||
80 | old = _raw_compare_and_swap(&lp->owner_cpu, 0, ~smp_processor_id()); | ||
81 | if (likely(old == 0)) | ||
82 | return; | ||
83 | _raw_spin_lock_wait_flags(lp, flags); | ||
76 | } | 84 | } |
77 | 85 | ||
78 | static inline int __raw_spin_trylock(raw_spinlock_t *lp) | 86 | static inline int __raw_spin_trylock(raw_spinlock_t *lp) |
79 | { | 87 | { |
80 | unsigned long pc = 1 | (unsigned long) __builtin_return_address(0); | ||
81 | int old; | 88 | int old; |
82 | 89 | ||
83 | old = _raw_compare_and_swap(&lp->owner_cpu, 0, ~smp_processor_id()); | 90 | old = _raw_compare_and_swap(&lp->owner_cpu, 0, ~smp_processor_id()); |
84 | if (likely(old == 0)) { | 91 | if (likely(old == 0)) |
85 | lp->owner_pc = pc; | ||
86 | return 1; | 92 | return 1; |
87 | } | 93 | return _raw_spin_trylock_retry(lp); |
88 | return _raw_spin_trylock_retry(lp, pc); | ||
89 | } | 94 | } |
90 | 95 | ||
91 | static inline void __raw_spin_unlock(raw_spinlock_t *lp) | 96 | static inline void __raw_spin_unlock(raw_spinlock_t *lp) |
92 | { | 97 | { |
93 | lp->owner_pc = 0; | ||
94 | _raw_compare_and_swap(&lp->owner_cpu, lp->owner_cpu, 0); | 98 | _raw_compare_and_swap(&lp->owner_cpu, lp->owner_cpu, 0); |
95 | } | 99 | } |
96 | 100 | ||