LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [2.6] Missing _raw_write_trylock for PPC/SMP
@ 2004-05-20 21:12 Kyle Moffett
  2004-05-21  0:19 ` Kyle Moffett
  0 siblings, 1 reply; 2+ messages in thread
From: Kyle Moffett @ 2004-05-20 21:12 UTC (permalink / raw)
  To: linux-kernel

The PPC/32 architecture is missing the SMP definition of the 
_raw_write_trylock
function.  I'm not strong enough on PowerPC assembly but it would be 
nice if
someone could write up an implementation for 
linux/include/asm-ppc/spinlock.h

Cheers,
Kyle Moffett


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [2.6] Missing _raw_write_trylock for PPC/SMP
  2004-05-20 21:12 [2.6] Missing _raw_write_trylock for PPC/SMP Kyle Moffett
@ 2004-05-21  0:19 ` Kyle Moffett
  0 siblings, 0 replies; 2+ messages in thread
From: Kyle Moffett @ 2004-05-21  0:19 UTC (permalink / raw)
  To: linux-kernel

On May 20, 2004, at 17:12, Kyle Moffett wrote:
> The PPC/32 architecture is missing the SMP definition of the 
> _raw_write_trylock
> function.  I'm not strong enough on PowerPC assembly but it would be 
> nice if
> someone could write up an implementation for 
> linux/include/asm-ppc/spinlock.h

I found the time to brush up on my assembly a little, and using the 
PPC/32 and
PPC/64 implementations of _raw_write_lock and the PPC/64 implementation
of _raw_write_trylock for reference I hacked together a patch.  There 
are
probably bugs in it as I'm still a little rusty, so it needs someone 
skilled in PPC
assembly to review it, but hopefully it will work.  I'll try compiling 
it into my
kernel tomorrow to see if it works. (I won't have access to the machine 
in
question untill then, sorry).

Cheers,
Kyle Moffett


--- a/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;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-05-21  7:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-20 21:12 [2.6] Missing _raw_write_trylock for PPC/SMP Kyle Moffett
2004-05-21  0:19 ` Kyle Moffett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).