linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arch@vger.kernel.org
Subject: PATCH : cmpxchg does not handle int * arguments on LP64
Date: Fri, 18 Jun 2010 14:51:56 +0200	[thread overview]
Message-ID: <1276865516.1999.18.camel@localhost.localdomain> (raw)

[-- Attachment #1: Type: text/plain, Size: 1521 bytes --]

hi,

I have been using the asm-generic/system.h header to implement my
version of arch/xx/include/asm/system.h: it appears that the version of
cmpxchg defined in this generic header does not handle correctly
non-long arguments on an LP64 arch. 

The attached patch appears to work on my port: I suspect that it's not
the right 'fix'. If so, I would be happy to be pointed in the right
direction. The following inline patch was generated against
davem/net-next-2.6/ (and attached to this email since I don't know what
the proper insertion policy is)

diff --git a/include/asm-generic/system.h b/include/asm-generic/system.h
index efa403b..da31909 100644
--- a/include/asm-generic/system.h
+++ b/include/asm-generic/system.h
@@ -136,24 +136,7 @@ unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
 #define xchg(ptr, x) \
 	((__typeof__(*(ptr))) __xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
 
-static inline unsigned long __cmpxchg(volatile unsigned long *m,
-				      unsigned long old, unsigned long new)
-{
-	unsigned long retval;
-	unsigned long flags;
-
-	local_irq_save(flags);
-	retval = *m;
-	if (retval == old)
-		*m = new;
-	local_irq_restore(flags);
-	return retval;
-}
-
-#define cmpxchg(ptr, o, n)					\
-	((__typeof__(*(ptr))) __cmpxchg((unsigned long *)(ptr), \
-					(unsigned long)(o),	\
-					(unsigned long)(n)))
+#define cmpxchg(ptr, o, n) cmpxchg_local(ptr, o, n)
 
 #endif /* !__ASSEMBLY__ */
 


Mathieu
-- 
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tel: +33 4 9238 5056

[-- Attachment #2: system.patch --]
[-- Type: text/x-patch, Size: 888 bytes --]

diff --git a/include/asm-generic/system.h b/include/asm-generic/system.h
index efa403b..da31909 100644
--- a/include/asm-generic/system.h
+++ b/include/asm-generic/system.h
@@ -136,24 +136,7 @@ unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
 #define xchg(ptr, x) \
 	((__typeof__(*(ptr))) __xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
 
-static inline unsigned long __cmpxchg(volatile unsigned long *m,
-				      unsigned long old, unsigned long new)
-{
-	unsigned long retval;
-	unsigned long flags;
-
-	local_irq_save(flags);
-	retval = *m;
-	if (retval == old)
-		*m = new;
-	local_irq_restore(flags);
-	return retval;
-}
-
-#define cmpxchg(ptr, o, n)					\
-	((__typeof__(*(ptr))) __cmpxchg((unsigned long *)(ptr), \
-					(unsigned long)(o),	\
-					(unsigned long)(n)))
+#define cmpxchg(ptr, o, n) cmpxchg_local(ptr, o, n)
 
 #endif /* !__ASSEMBLY__ */
 

             reply	other threads:[~2010-06-18 13:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-18 12:51 Mathieu Lacage [this message]
2010-06-18 13:30 ` PATCH : cmpxchg does not handle int * arguments on LP64 Arnd Bergmann
2010-06-18 14:37   ` Mathieu Lacage

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=1276865516.1999.18.camel@localhost.localdomain \
    --to=mathieu.lacage@sophia.inria.fr \
    --cc=arnd@arndb.de \
    --cc=linux-arch@vger.kernel.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).