[PATCH 2.6][REPOST] Missing _raw_write_trylock for PPC/SMP

From: Kyle Moffett
Date: Sat May 22 2004 - 23:45:58 EST


I just implemented _raw_write_trylock for PPC32 There are probably bugs in it as
I'm a little rusty on my PPC assembly. It needs someone skilled in PPC asm to look
at it, but hopefully it will work. It compiles, but nothing currently in the kernel proper
uses it aside from write_trylock which is also currently unused.

Cheers,
Kyle Moffett


--- linux-2.6.6/include/asm-ppc/spinlock.h 2004-05-09 22:32:28.000000000 -0400
+++ linux/include/asm-ppc/spinlock.h 2004-05-20 20:12:44.000000000 -0400
@@ -135,6 +135,28 @@
: "cr0", "memory");
}

+static __inline__ int _raw_write_trylock(rwlock_t *rw)
+{
+ unsigned int tmp;
+ unsigned int ret;
+
+ __asm__ __volatile__(
+"1: lwarx %0,0,%2 # write_trylock\n\
+ cmpwi 0,%0,0\n\
+ li %1,0\n\
+ bne- 2f\n"
+ PPC405_ERR77(0,%1)
+" stwcx. %3,0,%2\n\
+ bne- 1b\n\
+ li %1,1\n\
+ isync\n\
+2:" : "=&r"(tmp), "=&r"(ret)
+ : "r"(&rw->lock), "r"(-1)
+ : "cr0", "memory");
+
+ return ret;
+}
+
static __inline__ void _raw_write_lock(rwlock_t *rw)
{
unsigned int tmp;

Cheers,
Kyle Moffett

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/