From: Nick Piggin <npiggin@suse.de>
To: Paul Mackerras <paulus@samba.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
linuxppc-dev@ozlabs.org
Subject: [patch] xmon bitlock fix
Date: Tue, 20 Nov 2007 06:08:26 +0100 [thread overview]
Message-ID: <20071120050826.GA18332@wotan.suse.de> (raw)
(sorry, untested for lack of hardware)
--
xmon uses a bit lock spinlock but doesn't close the critical section
when releasing it. It doesn't seem like a big deal because it will
eventually break out of the lock anyway, but presumably that's only
in exceptional cases where some error is tolerated, while the lack of a memory
barrier could allow incorrect results during normal functioning operation
as well.
Convert it to use a regular spinlock instead.
Signed-off-by: Nick Piggin <npiggin@suse.de>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
Index: linux-2.6/arch/ppc/xmon/start.c
===================================================================
--- linux-2.6.orig/arch/ppc/xmon/start.c
+++ linux-2.6/arch/ppc/xmon/start.c
@@ -92,16 +92,14 @@ xmon_write(void *handle, void *ptr, int
{
char *p = ptr;
int i, c, ct;
-
-#ifdef CONFIG_SMP
- static unsigned long xmon_write_lock;
+ static DEFINE_SPINLOCK(xmon_write_lock);
int lock_wait = 1000000;
int locked;
- while ((locked = test_and_set_bit(0, &xmon_write_lock)) != 0)
+ while (!(locked = spin_trylock(&xmon_write_lock))) {
if (--lock_wait == 0)
break;
-#endif
+ }
if (!scc_initialized)
xmon_init_scc();
@@ -122,10 +120,9 @@ xmon_write(void *handle, void *ptr, int
eieio();
}
-#ifdef CONFIG_SMP
- if (!locked)
- clear_bit(0, &xmon_write_lock);
-#endif
+ if (locked)
+ spin_unlock(&xmon_write_lock);
+
return nb;
}
next reply other threads:[~2007-11-20 5:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-20 5:08 Nick Piggin [this message]
2007-11-20 5:09 ` [patch] powerpc: hash lock use lock bitops Nick Piggin
2007-11-20 6:08 ` Benjamin Herrenschmidt
2007-11-20 6:26 ` Nick Piggin
2007-11-20 7:10 ` Benjamin Herrenschmidt
2007-11-20 5:28 ` [patch] xmon bitlock fix Paul Mackerras
2007-11-20 6:03 ` Nick Piggin
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=20071120050826.GA18332@wotan.suse.de \
--to=npiggin@suse.de \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.org \
/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;
as well as URLs for NNTP newsgroup(s).