diff options
Diffstat (limited to 'include/asm-sparc/spinlock.h')
-rw-r--r-- | include/asm-sparc/spinlock.h | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/include/asm-sparc/spinlock.h b/include/asm-sparc/spinlock.h index 557d08959d2f..de2249b267c6 100644 --- a/include/asm-sparc/spinlock.h +++ b/include/asm-sparc/spinlock.h | |||
@@ -129,6 +129,7 @@ static inline void __raw_write_lock(raw_rwlock_t *rw) | |||
129 | : /* no outputs */ | 129 | : /* no outputs */ |
130 | : "r" (lp) | 130 | : "r" (lp) |
131 | : "g2", "g4", "memory", "cc"); | 131 | : "g2", "g4", "memory", "cc"); |
132 | *(volatile __u32 *)&lp->lock = ~0U; | ||
132 | } | 133 | } |
133 | 134 | ||
134 | static inline int __raw_write_trylock(raw_rwlock_t *rw) | 135 | static inline int __raw_write_trylock(raw_rwlock_t *rw) |
@@ -144,15 +145,40 @@ static inline int __raw_write_trylock(raw_rwlock_t *rw) | |||
144 | val = rw->lock & ~0xff; | 145 | val = rw->lock & ~0xff; |
145 | if (val) | 146 | if (val) |
146 | ((volatile u8*)&rw->lock)[3] = 0; | 147 | ((volatile u8*)&rw->lock)[3] = 0; |
148 | else | ||
149 | *(volatile u32*)&rw->lock = ~0U; | ||
147 | } | 150 | } |
148 | 151 | ||
149 | return (val == 0); | 152 | return (val == 0); |
150 | } | 153 | } |
151 | 154 | ||
155 | static inline int __read_trylock(raw_rwlock_t *rw) | ||
156 | { | ||
157 | register raw_rwlock_t *lp asm("g1"); | ||
158 | register int res asm("o0"); | ||
159 | lp = rw; | ||
160 | __asm__ __volatile__( | ||
161 | "mov %%o7, %%g4\n\t" | ||
162 | "call ___rw_read_try\n\t" | ||
163 | " ldstub [%%g1 + 3], %%g2\n" | ||
164 | : "=r" (res) | ||
165 | : "r" (lp) | ||
166 | : "g2", "g4", "memory", "cc"); | ||
167 | return res; | ||
168 | } | ||
169 | |||
170 | #define __raw_read_trylock(lock) \ | ||
171 | ({ unsigned long flags; \ | ||
172 | int res; \ | ||
173 | local_irq_save(flags); \ | ||
174 | res = __read_trylock(lock); \ | ||
175 | local_irq_restore(flags); \ | ||
176 | res; \ | ||
177 | }) | ||
178 | |||
152 | #define __raw_write_unlock(rw) do { (rw)->lock = 0; } while(0) | 179 | #define __raw_write_unlock(rw) do { (rw)->lock = 0; } while(0) |
153 | 180 | ||
154 | #define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock) | 181 | #define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock) |
155 | #define __raw_read_trylock(lock) generic__raw_read_trylock(lock) | ||
156 | 182 | ||
157 | #define _raw_spin_relax(lock) cpu_relax() | 183 | #define _raw_spin_relax(lock) cpu_relax() |
158 | #define _raw_read_relax(lock) cpu_relax() | 184 | #define _raw_read_relax(lock) cpu_relax() |