From: Thomas Koeller <thomas.koeller@baslerweb.com>
To: linux-mips@linux-mips.org
Subject: [PATCH] atomic functions broken
Date: Wed, 22 Feb 2006 21:25:39 +0100 [thread overview]
Message-ID: <200602222125.39999.thomas.koeller@baslerweb.com> (raw)
The ll/sc versions of atomic_sub_if_positive(), and the corresponding 64-bit functions,
are broken. The value returned by those functions is always one, no matter what.
Signed-off-by: Thomas Koeller <thomas.koeller@baslerweb.com>
diff --git a/include/asm-mips/atomic.h b/include/asm-mips/atomic.h
index 654b97d..472e855 100644
--- a/include/asm-mips/atomic.h
+++ b/include/asm-mips/atomic.h
@@ -247,15 +247,16 @@ static __inline__ int atomic_sub_if_posi
__asm__ __volatile__(
" .set mips3 \n"
"1: ll %1, %2 # atomic_sub_if_positive\n"
- " subu %0, %1, %3 \n"
- " bltz %0, 1f \n"
- " sc %0, %2 \n"
- " beqzl %0, 1b \n"
+ " subu %1, %1, %3 \n"
+ " addi %0, %1, 0 \n"
+ " bltz %1, 1f \n"
+ " sc %1, %2 \n"
+ " beqzl %1, 1b \n"
" sync \n"
"1: \n"
" .set mips0 \n"
- : "=&r" (result), "=&r" (temp), "=m" (v->counter)
- : "Ir" (i), "m" (v->counter)
+ : "=&r" (result), "=&r" (temp), "+m" (v->counter)
+ : "Ir" (i)
: "memory");
} else if (cpu_has_llsc) {
unsigned long temp;
@@ -263,15 +264,16 @@ static __inline__ int atomic_sub_if_posi
__asm__ __volatile__(
" .set mips3 \n"
"1: ll %1, %2 # atomic_sub_if_positive\n"
- " subu %0, %1, %3 \n"
- " bltz %0, 1f \n"
- " sc %0, %2 \n"
- " beqz %0, 1b \n"
+ " subu %1, %1, %3 \n"
+ " addi %0, %1, 0 \n"
+ " bltz %1, 1f \n"
+ " sc %1, %2 \n"
+ " beqz %1, 1b \n"
" sync \n"
"1: \n"
" .set mips0 \n"
- : "=&r" (result), "=&r" (temp), "=m" (v->counter)
- : "Ir" (i), "m" (v->counter)
+ : "=&r" (result), "=&r" (temp), "+m" (v->counter)
+ : "Ir" (i)
: "memory");
} else {
unsigned long flags;
@@ -595,15 +597,16 @@ static __inline__ long atomic64_sub_if_p
__asm__ __volatile__(
" .set mips3 \n"
"1: lld %1, %2 # atomic64_sub_if_positive\n"
- " dsubu %0, %1, %3 \n"
- " bltz %0, 1f \n"
- " scd %0, %2 \n"
- " beqzl %0, 1b \n"
+ " dsubu %1, %1, %3 \n"
+ " daddi %0, %1, 0 \n"
+ " bltz %1, 1f \n"
+ " scd %1, %2 \n"
+ " beqzl %1, 1b \n"
" sync \n"
"1: \n"
" .set mips0 \n"
- : "=&r" (result), "=&r" (temp), "=m" (v->counter)
- : "Ir" (i), "m" (v->counter)
+ : "=&r" (result), "=&r" (temp), "+m" (v->counter)
+ : "Ir" (i)
: "memory");
} else if (cpu_has_llsc) {
unsigned long temp;
@@ -611,15 +614,16 @@ static __inline__ long atomic64_sub_if_p
__asm__ __volatile__(
" .set mips3 \n"
"1: lld %1, %2 # atomic64_sub_if_positive\n"
- " dsubu %0, %1, %3 \n"
- " bltz %0, 1f \n"
- " scd %0, %2 \n"
- " beqz %0, 1b \n"
+ " dsubu %1, %1, %3 \n"
+ " daddi %0, %1, 0 \n"
+ " bltz %1, 1f \n"
+ " scd %1, %2 \n"
+ " beqz %1, 1b \n"
" sync \n"
"1: \n"
" .set mips0 \n"
- : "=&r" (result), "=&r" (temp), "=m" (v->counter)
- : "Ir" (i), "m" (v->counter)
+ : "=&r" (result), "=&r" (temp), "+m" (v->counter)
+ : "Ir" (i)
: "memory");
} else {
unsigned long flags;
--
--------------------------------------------------
Thomas Koeller, Software Development
Basler Vision Technologies
thomas dot koeller at baslerweb dot com
http://www.baslerweb.com
==============================
next reply other threads:[~2006-02-22 20:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-22 20:25 Thomas Koeller [this message]
2006-02-23 14:09 ` [PATCH] atomic functions broken Ralf Baechle
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=200602222125.39999.thomas.koeller@baslerweb.com \
--to=thomas.koeller@baslerweb.com \
--cc=linux-mips@linux-mips.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