From 7a39f52202a70ff6834e37053e2ee55c7d351621 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 8 Oct 2006 14:32:15 +0100 Subject: [PATCH] sparc32 rwlock fix read_trylock() is broken on sparc32 (doesn't build and didn't work right, actually). Proposed fix: - make "writer holds lock" distinguishable from "reader tries to grab lock" - have __raw_read_trylock() try to acquire the mutex (in LSB of lock), terminating spin if we see that there's writer holding it. Then do the rest as we do in read_lock(). Thanks to Ingo for discussion... Signed-off-by: Al Viro Signed-off-by: Linus Torvalds --- arch/sparc/lib/locks.S | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'arch/sparc/lib') diff --git a/arch/sparc/lib/locks.S b/arch/sparc/lib/locks.S index 95fa484..b1df55c 100644 --- a/arch/sparc/lib/locks.S +++ b/arch/sparc/lib/locks.S @@ -25,6 +25,15 @@ ___rw_read_enter_spin_on_wlock: ldstub [%g1 + 3], %g2 b ___rw_read_enter_spin_on_wlock ldub [%g1 + 3], %g2 +___rw_read_try_spin_on_wlock: + andcc %g2, 0xff, %g0 + be,a ___rw_read_try + ldstub [%g1 + 3], %g2 + xnorcc %g2, 0x0, %o0 /* if g2 is ~0, set o0 to 0 and bugger off */ + bne,a ___rw_read_enter_spin_on_wlock + ld [%g1], %g2 + retl + mov %g4, %o7 ___rw_read_exit_spin_on_wlock: orcc %g2, 0x0, %g0 be,a ___rw_read_exit @@ -60,6 +69,17 @@ ___rw_read_exit: retl mov %g4, %o7 + .globl ___rw_read_try +___rw_read_try: + orcc %g2, 0x0, %g0 + bne ___rw_read_try_spin_on_wlock + ld [%g1], %g2 + add %g2, 1, %g2 + st %g2, [%g1] + set 1, %o1 + retl + mov %g4, %o7 + .globl ___rw_write_enter ___rw_write_enter: orcc %g2, 0x0, %g0 -- cgit v1.1