aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/sparc/kernel/sparc_ksyms.c4
-rw-r--r--arch/sparc/lib/locks.S20
-rw-r--r--include/asm-sparc/spinlock.h28
3 files changed, 50 insertions, 2 deletions
diff --git a/arch/sparc/kernel/sparc_ksyms.c b/arch/sparc/kernel/sparc_ksyms.c
index 4d441a554d35..33dadd9f2871 100644
--- a/arch/sparc/kernel/sparc_ksyms.c
+++ b/arch/sparc/kernel/sparc_ksyms.c
@@ -87,6 +87,7 @@ extern void ___set_bit(void);
87extern void ___clear_bit(void); 87extern void ___clear_bit(void);
88extern void ___change_bit(void); 88extern void ___change_bit(void);
89extern void ___rw_read_enter(void); 89extern void ___rw_read_enter(void);
90extern void ___rw_read_try(void);
90extern void ___rw_read_exit(void); 91extern void ___rw_read_exit(void);
91extern void ___rw_write_enter(void); 92extern void ___rw_write_enter(void);
92 93
@@ -104,8 +105,9 @@ extern unsigned _Urem(unsigned, unsigned);
104EXPORT_SYMBOL(sparc_cpu_model); 105EXPORT_SYMBOL(sparc_cpu_model);
105EXPORT_SYMBOL(kernel_thread); 106EXPORT_SYMBOL(kernel_thread);
106#ifdef CONFIG_SMP 107#ifdef CONFIG_SMP
107// XXX find what uses (or used) these. 108// XXX find what uses (or used) these. AV: see asm/spinlock.h
108EXPORT_SYMBOL(___rw_read_enter); 109EXPORT_SYMBOL(___rw_read_enter);
110EXPORT_SYMBOL(___rw_read_try);
109EXPORT_SYMBOL(___rw_read_exit); 111EXPORT_SYMBOL(___rw_read_exit);
110EXPORT_SYMBOL(___rw_write_enter); 112EXPORT_SYMBOL(___rw_write_enter);
111#endif 113#endif
diff --git a/arch/sparc/lib/locks.S b/arch/sparc/lib/locks.S
index 95fa48424967..b1df55cb2215 100644
--- a/arch/sparc/lib/locks.S
+++ b/arch/sparc/lib/locks.S
@@ -25,6 +25,15 @@ ___rw_read_enter_spin_on_wlock:
25 ldstub [%g1 + 3], %g2 25 ldstub [%g1 + 3], %g2
26 b ___rw_read_enter_spin_on_wlock 26 b ___rw_read_enter_spin_on_wlock
27 ldub [%g1 + 3], %g2 27 ldub [%g1 + 3], %g2
28___rw_read_try_spin_on_wlock:
29 andcc %g2, 0xff, %g0
30 be,a ___rw_read_try
31 ldstub [%g1 + 3], %g2
32 xnorcc %g2, 0x0, %o0 /* if g2 is ~0, set o0 to 0 and bugger off */
33 bne,a ___rw_read_enter_spin_on_wlock
34 ld [%g1], %g2
35 retl
36 mov %g4, %o7
28___rw_read_exit_spin_on_wlock: 37___rw_read_exit_spin_on_wlock:
29 orcc %g2, 0x0, %g0 38 orcc %g2, 0x0, %g0
30 be,a ___rw_read_exit 39 be,a ___rw_read_exit
@@ -60,6 +69,17 @@ ___rw_read_exit:
60 retl 69 retl
61 mov %g4, %o7 70 mov %g4, %o7
62 71
72 .globl ___rw_read_try
73___rw_read_try:
74 orcc %g2, 0x0, %g0
75 bne ___rw_read_try_spin_on_wlock
76 ld [%g1], %g2
77 add %g2, 1, %g2
78 st %g2, [%g1]
79 set 1, %o1
80 retl
81 mov %g4, %o7
82
63 .globl ___rw_write_enter 83 .globl ___rw_write_enter
64___rw_write_enter: 84___rw_write_enter:
65 orcc %g2, 0x0, %g0 85 orcc %g2, 0x0, %g0
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
134static inline int __raw_write_trylock(raw_rwlock_t *rw) 135static 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
155static 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()