1 #ifndef __ASM_SPINLOCK_H
2 #define __ASM_SPINLOCK_H
27 #include <asm/asm-compat.h>
31 #define arch_spin_is_locked(x) ((x)->slock != 0)
35 #define LOCK_TOKEN (*(u32 *)(&get_paca()->lock_token))
40 #if defined(CONFIG_PPC64) && defined(CONFIG_SMP)
41 #define CLEAR_IO_SYNC (get_paca()->io_sync = 0)
42 #define SYNC_IO do { \
43 if (unlikely(get_paca()->io_sync)) { \
45 get_paca()->io_sync = 0; \
71 :
"r" (token),
"r" (&lock->
slock)
80 return __arch_spin_trylock(lock) == 0;
97 #if defined(CONFIG_PPC_SPLPAR)
99 #define SHARED_PROCESSOR (get_lppaca()->shared_proc)
103 #define __spin_yield(x) barrier()
104 #define __rw_yield(x) barrier()
105 #define SHARED_PROCESSOR 0
112 if (
likely(__arch_spin_trylock(lock) == 0))
116 if (SHARED_PROCESSOR)
126 unsigned long flags_dis;
130 if (
likely(__arch_spin_trylock(lock) == 0))
136 if (SHARED_PROCESSOR)
147 __asm__ __volatile__(
"# arch_spin_unlock\n\t"
148 PPC_RELEASE_BARRIER: : :
"memory");
155 #define arch_spin_unlock_wait(lock) \
156 do { while (arch_spin_is_locked(lock)) cpu_relax(); } while (0)
170 #define arch_read_can_lock(rw) ((rw)->lock >= 0)
171 #define arch_write_can_lock(rw) (!(rw)->lock)
174 #define __DO_SIGN_EXTEND "extsw %0,%0\n"
175 #define WRLOCK_TOKEN LOCK_TOKEN
177 #define __DO_SIGN_EXTEND
178 #define WRLOCK_TOKEN (-1)
200 :
"cr0",
"xer",
"memory");
213 token = WRLOCK_TOKEN;
223 :
"r" (token),
"r" (&rw->
lock)
232 if (
likely(__arch_read_trylock(rw) > 0))
236 if (SHARED_PROCESSOR)
246 if (
likely(__arch_write_trylock(rw) == 0))
250 if (SHARED_PROCESSOR)
259 return __arch_read_trylock(rw) > 0;
264 return __arch_write_trylock(rw) == 0;
281 :
"cr0",
"xer",
"memory");
286 __asm__ __volatile__(
"# write_unlock\n\t"
287 PPC_RELEASE_BARRIER: : :
"memory");
291 #define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
292 #define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
294 #define arch_spin_relax(lock) __spin_yield(lock)
295 #define arch_read_relax(lock) __rw_yield(lock)
296 #define arch_write_relax(lock) __rw_yield(lock)