]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[PATCH] SPARC64: Fix futex_atomic_cmpxchg_inatomic implementation.
authorDavid Miller <davem@davemloft.net>
Thu, 2 Nov 2006 05:55:00 +0000 (21:55 -0800)
committerChris Wright <chrisw@sous-sol.org>
Sun, 19 Nov 2006 03:27:58 +0000 (19:27 -0800)
I copied the logic from ll/sc arch implementations, but that
was wrong and makes no sense at all.  Just do a straight
compare-exchange instruction, just like x86.

Based upon bug reports from Dennis Gilmore and Fabio Massimo.

Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
include/asm-sparc64/futex.h

index dee40206b221f8d30d1e011faf79eedbea81402c..7392fc4a954e2d603805c319071bc1cbb89e2d19 100644 (file)
@@ -87,24 +87,22 @@ static inline int
 futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
 {
        __asm__ __volatile__(
-       "\n1:   lduwa   [%2] %%asi, %0\n"
-       "2:     casa    [%2] %%asi, %0, %1\n"
-       "3:\n"
+       "\n1:   casa    [%3] %%asi, %2, %0\n"
+       "2:\n"
        "       .section .fixup,#alloc,#execinstr\n"
        "       .align  4\n"
-       "4:     ba      3b\n"
-       "        mov    %3, %0\n"
+       "3:     ba      2b\n"
+       "        mov    %4, %0\n"
        "       .previous\n"
        "       .section __ex_table,\"a\"\n"
        "       .align  4\n"
-       "       .word   1b, 4b\n"
-       "       .word   2b, 4b\n"
+       "       .word   1b, 3b\n"
        "       .previous\n"
-       : "=&r" (oldval)
-       : "r" (newval), "r" (uaddr), "i" (-EFAULT)
+       : "=r" (newval)
+       : "0" (newval), "r" (oldval), "r" (uaddr), "i" (-EFAULT)
        : "memory");
 
-       return oldval;
+       return newval;
 }
 
 #endif /* !(_SPARC64_FUTEX_H) */