Skip to contentSkip to conversation

_raw_read_trylock for alpha

PATCH In review Jeff Garzik 2 participants 2 messages Mar 19, 2005 – Mar 20, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 _raw_read_trylock for alpha

alpha SMP doesn't build, due to lack of _raw_read_trylock().

Patch below completely untested... needs review and testing.

One could also use the arch-neutral generic_raw_read_trylock(), but that implementation is rather lame (it spins). I'm amazed at the number of arches that use the generic implementation, since the generic version isn't really a "trylock".

Don't send this patch upstream until its been verified to actually work.

include/asm-alpha/spinlock.h renamed from kernel-2.6.11.orig/linux-2.6.11/include/asm-alpha/spinlock.h +23 -0
diff -ur ../kernel-2.6.11.orig/linux-2.6.11/include/asm-alpha/spinlock.h linux-2.6.11/include/asm-alpha/spinlock.h
@@ -153,6 +153,29 @@
 }
 #endif /* CONFIG_DEBUG_RWLOCK */
 
+static inline int _raw_read_trylock(rwlock_t * lock)
+{
+	long regx;
+	int success;
+
+	__asm__ __volatile__(
+	"1:	ldl_l	%1,%0\n"
+	"	lda	%2,0\n"
+	"	blbs	%1,6f\n"
+	"	subl	%1,2,%1\n"
+	"	stl_c	%1,%0\n"
+	"	beq	%1,6f\n"
+	"	lda	%2,1\n"
+	"4:	mb\n"
+	".subsection 2\n"
+	"6:	br	1b\n"
+	".previous"
+	: "=m" (*lock), "=&r" (regx), "=&r" (success)
+	: "m" (*lock) : "memory");
+
+	return success;
+}
+
 static inline int _raw_write_trylock(rwlock_t * lock)
 {
 	long regx;
#1 lore raw
Quoted 1 line · Jeff Garzik

Don't send this patch upstream until its been verified to actually work.

It certainly won't. I'll gen up something soon.

r~