linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* PATCH : cmpxchg does not handle int * arguments on LP64
@ 2010-06-18 12:51 Mathieu Lacage
  2010-06-18 13:30 ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Mathieu Lacage @ 2010-06-18 12:51 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-arch

[-- 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__ */
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-06-18 14:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-18 12:51 PATCH : cmpxchg does not handle int * arguments on LP64 Mathieu Lacage
2010-06-18 13:30 ` Arnd Bergmann
2010-06-18 14:37   ` Mathieu Lacage

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).