From: Antonio SJ Musumeci <bile@landofbile.com>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Subject: Re: patch: include/asm-mips/system.h __cmpxchg64 bugfix and cleanup
Date: Wed, 18 Oct 2006 14:08:18 -0400 [thread overview]
Message-ID: <20061018140818.3e40b0a4@amiga> (raw)
In-Reply-To: <20061015184226.GA3259@linux-mips.org>
I'm not talking about that. This patch explains it. Moving
the conditional compilation from the optimizer to the preprocessor.
I see no reason to be using hard coded 1's and 0's in runtime logic.
And one could go all the way and check cpu_has_llsc to see if it's
hardcoded or not.
Signed-off-by: Antonio SJ Musumeci <bile@landofbile.com>
--- clean.linux.mips.git/include/asm-mips/system.h 2006-10-15 17:58:08.000000000 -0400
+++ linux.mips.git/include/asm-mips/system.h 2006-10-14 18:21:16.000000000 -0400
@@ -206,9 +206,9 @@ static inline unsigned long __xchg_u32(v
{
__u32 retval;
- if (cpu_has_llsc && R10000_LLSC_WAR) {
+ if (cpu_has_llsc) {
unsigned long dummy;
-
+#if R10000_LLSC_WAR
__asm__ __volatile__(
" .set mips3 \n"
"1: ll %0, %3 # xchg_u32 \n"
@@ -217,16 +217,14 @@ static inline unsigned long __xchg_u32(v
" .set mips3 \n"
" sc %2, %1 \n"
" beqzl %2, 1b \n"
-#ifdef CONFIG_SMP
+# ifdef CONFIG_SMP
" sync \n"
-#endif
+# endif
" .set mips0 \n"
: "=&r" (retval), "=m" (*m), "=&r" (dummy)
: "R" (*m), "Jr" (val)
: "memory");
- } else if (cpu_has_llsc) {
- unsigned long dummy;
-
+#else /* !R10000_LLSC_WAR */
__asm__ __volatile__(
" .set mips3 \n"
"1: ll %0, %3 # xchg_u32 \n"
@@ -235,9 +233,9 @@ static inline unsigned long __xchg_u32(v
" .set mips3 \n"
" sc %2, %1 \n"
" beqz %2, 2f \n"
-#ifdef CONFIG_SMP
+# ifdef CONFIG_SMP
" sync \n"
-#endif
+# endif
" .subsection 2 \n"
"2: b 1b \n"
" .previous \n"
@@ -245,8 +243,9 @@ static inline unsigned long __xchg_u32(v
: "=&r" (retval), "=m" (*m), "=&r" (dummy)
: "R" (*m), "Jr" (val)
: "memory");
+#endif /* R10000_LLSC_WAR */
} else {
- unsigned long flags;
+ unsigned long flags;
local_irq_save(flags);
retval = *m;
@@ -262,34 +261,32 @@ static inline __u64 __xchg_u64(volatile
{
__u64 retval;
- if (cpu_has_llsc && R10000_LLSC_WAR) {
+ if (cpu_has_llsc) {
unsigned long dummy;
-
+#if R10000_LLSC_WAR
__asm__ __volatile__(
" .set mips3 \n"
"1: lld %0, %3 # xchg_u64 \n"
" move %2, %z4 \n"
" scd %2, %1 \n"
" beqzl %2, 1b \n"
-#ifdef CONFIG_SMP
+# ifdef CONFIG_SMP
" sync \n"
-#endif
+# endif
" .set mips0 \n"
: "=&r" (retval), "=m" (*m), "=&r" (dummy)
: "R" (*m), "Jr" (val)
: "memory");
- } else if (cpu_has_llsc) {
- unsigned long dummy;
-
- __asm__ __volatile__(
+#else /* !R10000_LLSC_WAR */
+ __asm__ __volatile__(
" .set mips3 \n"
"1: lld %0, %3 # xchg_u64 \n"
" move %2, %z4 \n"
" scd %2, %1 \n"
" beqz %2, 2f \n"
-#ifdef CONFIG_SMP
+# ifdef CONFIG_SMP
" sync \n"
-#endif
+# endif
" .subsection 2 \n"
"2: b 1b \n"
" .previous \n"
@@ -297,6 +294,8 @@ static inline __u64 __xchg_u64(volatile
: "=&r" (retval), "=m" (*m), "=&r" (dummy)
: "R" (*m), "Jr" (val)
: "memory");
+
+#endif /* R10000_LLSC_WAR */
} else {
unsigned long flags;
@@ -339,7 +338,8 @@ static inline unsigned long __cmpxchg_u3
{
__u32 retval;
- if (cpu_has_llsc && R10000_LLSC_WAR) {
+ if (cpu_has_llsc) {
+#if R10000_LLSC_WAR
__asm__ __volatile__(
" .set push \n"
" .set noat \n"
@@ -351,15 +351,15 @@ static inline unsigned long __cmpxchg_u3
" .set mips3 \n"
" sc $1, %1 \n"
" beqzl $1, 1b \n"
-#ifdef CONFIG_SMP
+# ifdef CONFIG_SMP
" sync \n"
-#endif
+# endif
"2: \n"
" .set pop \n"
: "=&r" (retval), "=R" (*m)
: "R" (*m), "Jr" (old), "Jr" (new)
: "memory");
- } else if (cpu_has_llsc) {
+#else /* !R10000_LLSC_WAR */
__asm__ __volatile__(
" .set push \n"
" .set noat \n"
@@ -371,9 +371,9 @@ static inline unsigned long __cmpxchg_u3
" .set mips3 \n"
" sc $1, %1 \n"
" beqz $1, 3f \n"
-#ifdef CONFIG_SMP
+# ifdef CONFIG_SMP
" sync \n"
-#endif
+# endif
"2: \n"
" .subsection 2 \n"
"3: b 1b \n"
@@ -382,6 +382,7 @@ static inline unsigned long __cmpxchg_u3
: "=&r" (retval), "=R" (*m)
: "R" (*m), "Jr" (old), "Jr" (new)
: "memory");
+#endif /* R10000_LLSC_WAR */
} else {
unsigned long flags;
@@ -401,8 +402,9 @@ static inline unsigned long __cmpxchg_u6
{
__u64 retval;
- if (cpu_has_llsc && R10000_LLSC_WAR) {
- __asm__ __volatile__(
+ if (cpu_has_llsc) {
+#if R10000_LLSC_WAR
+ __asm__ __volatile__(
" .set push \n"
" .set noat \n"
" .set mips3 \n"
@@ -411,15 +413,15 @@ static inline unsigned long __cmpxchg_u6
" move $1, %z4 \n"
" scd $1, %1 \n"
" beqzl $1, 1b \n"
-#ifdef CONFIG_SMP
+# ifdef CONFIG_SMP
" sync \n"
-#endif
+# endif
"2: \n"
" .set pop \n"
: "=&r" (retval), "=R" (*m)
: "R" (*m), "Jr" (old), "Jr" (new)
: "memory");
- } else if (cpu_has_llsc) {
+#else /* !R10000_LLSC_WAR */
__asm__ __volatile__(
" .set push \n"
" .set noat \n"
@@ -429,9 +431,9 @@ static inline unsigned long __cmpxchg_u6
" move $1, %z4 \n"
" scd $1, %1 \n"
" beqz $1, 3f \n"
-#ifdef CONFIG_SMP
+# ifdef CONFIG_SMP
" sync \n"
-#endif
+# endif
"2: \n"
" .subsection 2 \n"
"3: b 1b \n"
@@ -440,6 +442,7 @@ static inline unsigned long __cmpxchg_u6
: "=&r" (retval), "=R" (*m)
: "R" (*m), "Jr" (old), "Jr" (new)
: "memory");
+#endif /* R10000_LLSC_WAR */
} else {
unsigned long flags;
On Sun, 15 Oct 2006 19:42:26 +0100
Ralf Baechle <ralf@linux-mips.org> wrote:
> On Fri, Oct 13, 2006 at 03:18:41PM -0400, Antonio SJ Musumeci wrote:
>
> > Wouldn't it be better to check the macro in the preprocessor
> > instead of runtime? And why are those defined to 0 instead of
> > explicitly undef'ed? I've found one bug because it was assumed to
> > be undefined instead of 0. If no one objects I'll post a patch
> > undefing those and fix any bugs I've found because of them.
>
> Any reasonable system configuration will define cpu_has_llsc to 1 in
> order to override the default. R10000_LLSC_WAR is a constant as well.
> So only one of the three if blocks will remain. If that's not the
> case you either don't have a cpu-feature-overrides.h file for your
> platform or it doesn't define cpu_has_llsc to a constant expression.
>
> Ralf
>
>
next prev parent reply other threads:[~2006-10-18 18:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-12 18:03 patch: include/asm-mips/system.h __cmpxchg64 bugfix and cleanup bile
2006-10-13 10:42 ` Ralf Baechle
2006-10-13 13:53 ` Antonio SJ Musumeci
2006-10-13 14:11 ` Ralf Baechle
2006-10-13 19:18 ` Antonio SJ Musumeci
2006-10-15 18:42 ` Ralf Baechle
2006-10-18 18:08 ` Antonio SJ Musumeci [this message]
2006-10-18 18:41 ` Thiemo Seufer
2006-10-18 19:45 ` Antonio SJ Musumeci
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=20061018140818.3e40b0a4@amiga \
--to=bile@landofbile.com \
--cc=linux-mips@linux-mips.org \
--cc=ralf@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.