Skip to contentSkip to conversation

missing _raw_write_trylock

PATCH In review Jun Sun 4 participants 5 messages Mar 16, 2004 MIPS

lore
Share & tools
lore

Jun Sun

author
#0 lore raw

PATCH 1/1 missing _raw_write_trylock

Please help me reviewing the code, because inline assembly bug is always tricky and miserable.

Jun

include/asm-mips/spinlock.h renamed from include/asm-mips/spinlock.h.orig +24 -0
diff -Nru linux/include/asm-mips/spinlock.h.orig linux/include/asm-mips/spinlock.h
@@ -167,4 +167,28 @@
 	: "memory");
 }
 
+static inline int _raw_write_trylock(rwlock_t *rw)
+{
+	unsigned int tmp;
+	int ret;
+
+	__asm__ __volatile__(
+	".set\tnoreorder\t\t\t# _raw_write_trylock\n"
+	"li\t%2, 0\n\t"
+	"1:\tll\t%1, %3\n\t"
+	"bnez\t%1, 2f\n\t"
+	"lui\t%1, 0x8000\n\t"
+	"sc\t%1, %0\n\t"
+	"beqz\t%1, 1b\n\t"
+	"sync\n\t"
+	"li\t%2, 1\n\t"
+	".set\treorder\n"
+	"2:"
+	: "=m" (rw->lock), "=&r" (tmp), "=&r" (ret)
+	: "m" (rw->lock)
+	: "memory");
+
+	return ret;
+}
+
 #endif /* _ASM_SPINLOCK_H */
#1 lore raw
Quoted 3 lines · Jun Sun

Please help me reviewing the code, because inline assembly bug is always tricky and miserable.

Are you going to do a non-LLSC, or are we no longer concerned about those?

-Steve

author
#2 lore raw
Quoted 7 lines · Steven J. Hill
Quoted 3 lines · Jun Sun

Please help me reviewing the code, because inline assembly bug is always tricky and miserable.

Are you going to do a non-LLSC, or are we no longer concerned about those?

For SMP machines we assume LLSC are present. This function and its friends for SMP only.

Jun

#3 lore raw
Quoted 6 lines · Jun Sun
Quoted 3 lines

Are you going to do a non-LLSC, or are we no longer concerned about those?

For SMP machines we assume LLSC are present. This function and its friends for SMP only.

doesn't CONFIG_PREEMPT (*shudder*) need it is aswell?

#4 lore raw

CONFIG_SMP and CONFIG_PREEMPT at the same time, as it's in
kernel/sched.c.

chris

Quoted 11 lines · Christoph Hellwig
Quoted 6 lines · Jun Sun
Quoted 3 lines

Are you going to do a non-LLSC, or are we no longer concerned about those?

For SMP machines we assume LLSC are present. This function and its friends for SMP only.

doesn't CONFIG_PREEMPT (*shudder*) need it is aswell?