diff options
author | Al Viro <viro@parcelfarce.linux.theplanet.co.uk> | 2005-04-20 20:12:41 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2005-04-20 20:12:41 -0400 |
commit | 489ec5f5d59b306e4ccc505eac417526adedb438 (patch) | |
tree | 506d4be0182ca0a434c70e1267087646644a0e69 /include | |
parent | 4d78b6c78ae6d87e4c1c8072f42efa716f04afb9 (diff) |
[SPARC64]: sparc64 preempt + smp
PREEMPT+SMP support - see if it looks sane...
Signed-off-by: Al Viro <viro@parcelfarce.linux.theplanet.co.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-sparc64/spinlock.h | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/include/asm-sparc64/spinlock.h b/include/asm-sparc64/spinlock.h index 11efa474865b..d1f91a4f24ae 100644 --- a/include/asm-sparc64/spinlock.h +++ b/include/asm-sparc64/spinlock.h | |||
@@ -31,15 +31,20 @@ | |||
31 | 31 | ||
32 | #ifndef CONFIG_DEBUG_SPINLOCK | 32 | #ifndef CONFIG_DEBUG_SPINLOCK |
33 | 33 | ||
34 | typedef unsigned char spinlock_t; | 34 | typedef struct { |
35 | #define SPIN_LOCK_UNLOCKED 0 | 35 | volatile unsigned char lock; |
36 | #ifdef CONFIG_PREEMPT | ||
37 | unsigned int break_lock; | ||
38 | #endif | ||
39 | } spinlock_t; | ||
40 | #define SPIN_LOCK_UNLOCKED (spinlock_t) {0,} | ||
36 | 41 | ||
37 | #define spin_lock_init(lock) (*((unsigned char *)(lock)) = 0) | 42 | #define spin_lock_init(lp) do { *(lp)= SPIN_LOCK_UNLOCKED; } while(0) |
38 | #define spin_is_locked(lock) (*((volatile unsigned char *)(lock)) != 0) | 43 | #define spin_is_locked(lp) ((lp)->lock != 0) |
39 | 44 | ||
40 | #define spin_unlock_wait(lock) \ | 45 | #define spin_unlock_wait(lp) \ |
41 | do { membar("#LoadLoad"); \ | 46 | do { membar("#LoadLoad"); \ |
42 | } while(*((volatile unsigned char *)lock)) | 47 | } while(lp->lock) |
43 | 48 | ||
44 | static inline void _raw_spin_lock(spinlock_t *lock) | 49 | static inline void _raw_spin_lock(spinlock_t *lock) |
45 | { | 50 | { |
@@ -109,20 +114,19 @@ static inline void _raw_spin_lock_flags(spinlock_t *lock, unsigned long flags) | |||
109 | #else /* !(CONFIG_DEBUG_SPINLOCK) */ | 114 | #else /* !(CONFIG_DEBUG_SPINLOCK) */ |
110 | 115 | ||
111 | typedef struct { | 116 | typedef struct { |
112 | unsigned char lock; | 117 | volatile unsigned char lock; |
113 | unsigned int owner_pc, owner_cpu; | 118 | unsigned int owner_pc, owner_cpu; |
119 | #ifdef CONFIG_PREEMPT | ||
120 | unsigned int break_lock; | ||
121 | #endif | ||
114 | } spinlock_t; | 122 | } spinlock_t; |
115 | #define SPIN_LOCK_UNLOCKED (spinlock_t) { 0, 0, 0xff } | 123 | #define SPIN_LOCK_UNLOCKED (spinlock_t) { 0, 0, 0xff } |
116 | #define spin_lock_init(__lock) \ | 124 | #define spin_lock_init(lp) do { *(lp)= SPIN_LOCK_UNLOCKED; } while(0) |
117 | do { (__lock)->lock = 0; \ | 125 | #define spin_is_locked(__lock) ((__lock)->lock != 0) |
118 | (__lock)->owner_pc = 0; \ | ||
119 | (__lock)->owner_cpu = 0xff; \ | ||
120 | } while(0) | ||
121 | #define spin_is_locked(__lock) (*((volatile unsigned char *)(&((__lock)->lock))) != 0) | ||
122 | #define spin_unlock_wait(__lock) \ | 126 | #define spin_unlock_wait(__lock) \ |
123 | do { \ | 127 | do { \ |
124 | membar("#LoadLoad"); \ | 128 | membar("#LoadLoad"); \ |
125 | } while(*((volatile unsigned char *)(&((__lock)->lock)))) | 129 | } while((__lock)->lock) |
126 | 130 | ||
127 | extern void _do_spin_lock (spinlock_t *lock, char *str); | 131 | extern void _do_spin_lock (spinlock_t *lock, char *str); |
128 | extern void _do_spin_unlock (spinlock_t *lock); | 132 | extern void _do_spin_unlock (spinlock_t *lock); |
@@ -139,8 +143,13 @@ extern int _do_spin_trylock (spinlock_t *lock); | |||
139 | 143 | ||
140 | #ifndef CONFIG_DEBUG_SPINLOCK | 144 | #ifndef CONFIG_DEBUG_SPINLOCK |
141 | 145 | ||
142 | typedef unsigned int rwlock_t; | 146 | typedef struct { |
143 | #define RW_LOCK_UNLOCKED 0 | 147 | volatile unsigned int lock; |
148 | #ifdef CONFIG_PREEMPT | ||
149 | unsigned int break_lock; | ||
150 | #endif | ||
151 | } rwlock_t; | ||
152 | #define RW_LOCK_UNLOCKED {0,} | ||
144 | #define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0) | 153 | #define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0) |
145 | 154 | ||
146 | static void inline __read_lock(rwlock_t *lock) | 155 | static void inline __read_lock(rwlock_t *lock) |
@@ -251,9 +260,12 @@ static int inline __write_trylock(rwlock_t *lock) | |||
251 | #else /* !(CONFIG_DEBUG_SPINLOCK) */ | 260 | #else /* !(CONFIG_DEBUG_SPINLOCK) */ |
252 | 261 | ||
253 | typedef struct { | 262 | typedef struct { |
254 | unsigned long lock; | 263 | volatile unsigned long lock; |
255 | unsigned int writer_pc, writer_cpu; | 264 | unsigned int writer_pc, writer_cpu; |
256 | unsigned int reader_pc[NR_CPUS]; | 265 | unsigned int reader_pc[NR_CPUS]; |
266 | #ifdef CONFIG_PREEMPT | ||
267 | unsigned int break_lock; | ||
268 | #endif | ||
257 | } rwlock_t; | 269 | } rwlock_t; |
258 | #define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0, 0xff, { } } | 270 | #define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0, 0xff, { } } |
259 | #define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0) | 271 | #define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0) |
@@ -304,6 +316,8 @@ do { unsigned long flags; \ | |||
304 | #endif /* CONFIG_DEBUG_SPINLOCK */ | 316 | #endif /* CONFIG_DEBUG_SPINLOCK */ |
305 | 317 | ||
306 | #define _raw_read_trylock(lock) generic_raw_read_trylock(lock) | 318 | #define _raw_read_trylock(lock) generic_raw_read_trylock(lock) |
319 | #define read_can_lock(rw) (!((rw)->lock & 0x80000000UL)) | ||
320 | #define write_can_lock(rw) (!(rw)->lock) | ||
307 | 321 | ||
308 | #endif /* !(__ASSEMBLY__) */ | 322 | #endif /* !(__ASSEMBLY__) */ |
309 | 323 | ||