diff options
Diffstat (limited to 'arch/powerpc/include/asm/spinlock.h')
-rw-r--r-- | arch/powerpc/include/asm/spinlock.h | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h index 764094cff681..f9611bd69ed2 100644 --- a/arch/powerpc/include/asm/spinlock.h +++ b/arch/powerpc/include/asm/spinlock.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #endif | 27 | #endif |
28 | #include <asm/asm-compat.h> | 28 | #include <asm/asm-compat.h> |
29 | #include <asm/synch.h> | 29 | #include <asm/synch.h> |
30 | #include <asm/ppc-opcode.h> | ||
30 | 31 | ||
31 | #define arch_spin_is_locked(x) ((x)->slock != 0) | 32 | #define arch_spin_is_locked(x) ((x)->slock != 0) |
32 | 33 | ||
@@ -60,13 +61,14 @@ static inline unsigned long __arch_spin_trylock(arch_spinlock_t *lock) | |||
60 | 61 | ||
61 | token = LOCK_TOKEN; | 62 | token = LOCK_TOKEN; |
62 | __asm__ __volatile__( | 63 | __asm__ __volatile__( |
63 | "1: lwarx %0,0,%2\n\ | 64 | "1: " PPC_LWARX(%0,0,%2,1) "\n\ |
64 | cmpwi 0,%0,0\n\ | 65 | cmpwi 0,%0,0\n\ |
65 | bne- 2f\n\ | 66 | bne- 2f\n\ |
66 | stwcx. %1,0,%2\n\ | 67 | stwcx. %1,0,%2\n\ |
67 | bne- 1b\n\ | 68 | bne- 1b\n" |
68 | isync\n\ | 69 | PPC_ACQUIRE_BARRIER |
69 | 2:" : "=&r" (tmp) | 70 | "2:" |
71 | : "=&r" (tmp) | ||
70 | : "r" (token), "r" (&lock->slock) | 72 | : "r" (token), "r" (&lock->slock) |
71 | : "cr0", "memory"); | 73 | : "cr0", "memory"); |
72 | 74 | ||
@@ -144,7 +146,7 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock) | |||
144 | { | 146 | { |
145 | SYNC_IO; | 147 | SYNC_IO; |
146 | __asm__ __volatile__("# arch_spin_unlock\n\t" | 148 | __asm__ __volatile__("# arch_spin_unlock\n\t" |
147 | LWSYNC_ON_SMP: : :"memory"); | 149 | PPC_RELEASE_BARRIER: : :"memory"); |
148 | lock->slock = 0; | 150 | lock->slock = 0; |
149 | } | 151 | } |
150 | 152 | ||
@@ -186,15 +188,15 @@ static inline long __arch_read_trylock(arch_rwlock_t *rw) | |||
186 | long tmp; | 188 | long tmp; |
187 | 189 | ||
188 | __asm__ __volatile__( | 190 | __asm__ __volatile__( |
189 | "1: lwarx %0,0,%1\n" | 191 | "1: " PPC_LWARX(%0,0,%1,1) "\n" |
190 | __DO_SIGN_EXTEND | 192 | __DO_SIGN_EXTEND |
191 | " addic. %0,%0,1\n\ | 193 | " addic. %0,%0,1\n\ |
192 | ble- 2f\n" | 194 | ble- 2f\n" |
193 | PPC405_ERR77(0,%1) | 195 | PPC405_ERR77(0,%1) |
194 | " stwcx. %0,0,%1\n\ | 196 | " stwcx. %0,0,%1\n\ |
195 | bne- 1b\n\ | 197 | bne- 1b\n" |
196 | isync\n\ | 198 | PPC_ACQUIRE_BARRIER |
197 | 2:" : "=&r" (tmp) | 199 | "2:" : "=&r" (tmp) |
198 | : "r" (&rw->lock) | 200 | : "r" (&rw->lock) |
199 | : "cr0", "xer", "memory"); | 201 | : "cr0", "xer", "memory"); |
200 | 202 | ||
@@ -211,14 +213,14 @@ static inline long __arch_write_trylock(arch_rwlock_t *rw) | |||
211 | 213 | ||
212 | token = WRLOCK_TOKEN; | 214 | token = WRLOCK_TOKEN; |
213 | __asm__ __volatile__( | 215 | __asm__ __volatile__( |
214 | "1: lwarx %0,0,%2\n\ | 216 | "1: " PPC_LWARX(%0,0,%2,1) "\n\ |
215 | cmpwi 0,%0,0\n\ | 217 | cmpwi 0,%0,0\n\ |
216 | bne- 2f\n" | 218 | bne- 2f\n" |
217 | PPC405_ERR77(0,%1) | 219 | PPC405_ERR77(0,%1) |
218 | " stwcx. %1,0,%2\n\ | 220 | " stwcx. %1,0,%2\n\ |
219 | bne- 1b\n\ | 221 | bne- 1b\n" |
220 | isync\n\ | 222 | PPC_ACQUIRE_BARRIER |
221 | 2:" : "=&r" (tmp) | 223 | "2:" : "=&r" (tmp) |
222 | : "r" (token), "r" (&rw->lock) | 224 | : "r" (token), "r" (&rw->lock) |
223 | : "cr0", "memory"); | 225 | : "cr0", "memory"); |
224 | 226 | ||
@@ -269,7 +271,7 @@ static inline void arch_read_unlock(arch_rwlock_t *rw) | |||
269 | 271 | ||
270 | __asm__ __volatile__( | 272 | __asm__ __volatile__( |
271 | "# read_unlock\n\t" | 273 | "# read_unlock\n\t" |
272 | LWSYNC_ON_SMP | 274 | PPC_RELEASE_BARRIER |
273 | "1: lwarx %0,0,%1\n\ | 275 | "1: lwarx %0,0,%1\n\ |
274 | addic %0,%0,-1\n" | 276 | addic %0,%0,-1\n" |
275 | PPC405_ERR77(0,%1) | 277 | PPC405_ERR77(0,%1) |
@@ -283,7 +285,7 @@ static inline void arch_read_unlock(arch_rwlock_t *rw) | |||
283 | static inline void arch_write_unlock(arch_rwlock_t *rw) | 285 | static inline void arch_write_unlock(arch_rwlock_t *rw) |
284 | { | 286 | { |
285 | __asm__ __volatile__("# write_unlock\n\t" | 287 | __asm__ __volatile__("# write_unlock\n\t" |
286 | LWSYNC_ON_SMP: : :"memory"); | 288 | PPC_RELEASE_BARRIER: : :"memory"); |
287 | rw->lock = 0; | 289 | rw->lock = 0; |
288 | } | 290 | } |
289 | 291 | ||