| To: | linux-mips@linux-mips.org |
|---|---|
| Subject: | Bug in atomic_sub_if_positive |
| From: | "Morten Larsen" <mlarsen@broadcom.com> |
| Date: | Wed, 25 Jun 2008 23:07:24 -0700 |
| Original-recipient: | rfc822;linux-mips@linux-mips.org |
| Sender: | linux-mips-bounce@linux-mips.org |
| Thread-index: | AcjXUubV9JI/8zo6QlaMem/+HdxMfQ== |
| Thread-topic: | Bug in atomic_sub_if_positive |
As far as I can tell the branch optimization fixes in 2.6.21 introduced
a bug in atomic_sub_if_positive that causes it to return even when the
sc instruction fails. The result is that e.g. down_trylock becomes
unreliable as the semaphore counter is not always decremented.
Below is a patch that fixed the problem on my system.
Morten S. Larsen
--- a/include/asm-mips/atomic.h 2008-06-25 22:38:43.159739000 -0700
+++ b/include/asm-mips/atomic.h 2008-06-25 22:39:07.552065000 -0700
@@ -292,10 +292,10 @@ static __inline__ int atomic_sub_if_posi
" beqz %0, 2f
\n"
" subu %0, %1, %3
\n"
" .set reorder
\n"
- "1:
\n"
" .subsection 2
\n"
"2: b 1b
\n"
" .previous
\n"
+ "1:
\n"
" .set mips0
\n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter)
@@ -682,10 +682,10 @@ static __inline__ long atomic64_sub_if_p
" beqz %0, 2f
\n"
" dsubu %0, %1, %3
\n"
" .set reorder
\n"
- "1:
\n"
" .subsection 2
\n"
"2: b 1b
\n"
" .previous
\n"
+ "1:
\n"
" .set mips0
\n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter)
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: [2.6 patch] remove pcibios_update_resource() functions, Ralf Baechle |
|---|---|
| Next by Date: | Re: [PATCH] Fix IP32 unexpected irq 71, Ralf Baechle |
| Previous by Thread: | [PATCH] gbefb: cmap FIFO timeout, Thomas Bogendoerfer |
| Next by Thread: | Re: Bug in atomic_sub_if_positive, Ralf Baechle |
| Indexes: | [Date] [Thread] [Top] [All Lists] |