public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Garzik <jgarzik@redhat.com>
To: rth@redhat.com, akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: [PATCH] _raw_read_trylock for alpha
Date: Sat, 19 Mar 2005 15:39:33 -0500	[thread overview]
Message-ID: <20050319203933.GD7404@devserv.devel.redhat.com> (raw)


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.

Signed-off-by: Jeff Garzik <jgarzik@pobox.com>


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
--- ../kernel-2.6.11.orig/linux-2.6.11/include/asm-alpha/spinlock.h	2005-03-02 02:38:12.000000000 -0500
+++ linux-2.6.11/include/asm-alpha/spinlock.h	2005-03-19 03:26:11.000000000 -0500
@@ -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;

             reply	other threads:[~2005-03-19 20:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-19 20:39 Jeff Garzik [this message]
2005-03-20  2:40 ` [PATCH] _raw_read_trylock for alpha Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050319203933.GD7404@devserv.devel.redhat.com \
    --to=jgarzik@redhat.com \
    --cc=akpm@osdl.org \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox