sparc: Provide cmpxchg64 for 32-bit builds
PATCH 1/1 sparc: Provide cmpxchg64 for 32-bit builds
Fix the following build error, seen when building sparc32:allmodconfig.
drivers/net/ethernet/intel/i40e/i40e_ethtool.c:
In function 'i40e_set_priv_flags':drivers/net/ethernet/intel/i40e/i40e_ethtool.c:4150:2: error:
implicit declaration of function 'cmpxchg64'
--- arch/sparc/include/asm/cmpxchg_32.h | 1 + 1 file changed, 1 insertion(+)
arch/sparc/include/asm/cmpxchg_32.h +1 -0
@@ -72,5 +72,6 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size) ((__typeof__ (*(ptr )))__cmpxchg_local_generic ((ptr), (unsigned long )(o),\ (unsigned long)(n), sizeof(*(ptr))))#define cmpxchg64_local (ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n)) +#define cmpxchg64 (ptr, o, n) cmpxchg64_local((ptr), (o), (n))#endif /* __ARCH_SPARC_CMPXCHG__ */
Signature · 1 line
2.7.4
David Miller
maintainerFrom: Guenter Roeck <[email protected]>
Date: Sun, 24 Sep 2017 10:29:31 -0700
Quoted 8 lines
Fix the following build error, seen when building sparc32:allmodconfig.
drivers/net/ethernet/intel/i40e/i40e_ethtool.c:
In function 'i40e_set_priv_flags':drivers/net/ethernet/intel/i40e/i40e_ethtool.c:4150:2: error:
implicit declaration of function 'cmpxchg64'Signed-off-by Guenter Roeck <[email protected]>
That fixes the build:
arch/sparc/include/asm/cmpxchg_32.h __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size) · line 77
Quoted 7 lines
arch/sparc/include/asm/cmpxchg_32.h +1
-0@@ -72,5 +72,6 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size) ((__typeof__ (*(ptr )))__cmpxchg_local_generic ((ptr), (unsigned long )(o),\ (unsigned long)(n), sizeof(*(ptr))))#define cmpxchg64_local (ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n)) +#define cmpxchg64 (ptr, o, n) cmpxchg64_local((ptr), (o), (n))#endif /* __ARCH_SPARC_CMPXCHG__ */
but it's wrong. cmpxchg64_local() is only atomic on the current cpu so using it for plain cmpxchg64() is not going to work.
Quoted 20 lines · David Miller
From: Guenter Roeck <[email protected]>
Date: Sun, 24 Sep 2017 10:29:31 -0700Quoted 8 lines
Fix the following build error, seen when building sparc32:allmodconfig.
drivers/net/ethernet/intel/i40e/i40e_ethtool.c:
In function 'i40e_set_priv_flags':drivers/net/ethernet/intel/i40e/i40e_ethtool.c:4150:2: error:
implicit declaration of function 'cmpxchg64'Signed-off-by Guenter Roeck <[email protected]>That fixes the build:
Quoted 6 lines
arch/sparc/include/asm/cmpxchg_32.h +1
-0@@ -72,5 +72,6 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size) ((__typeof__ (*(ptr )))__cmpxchg_local_generic ((ptr), (unsigned long )(o),\ (unsigned long)(n), sizeof(*(ptr))))#define cmpxchg64_local (ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n)) +#define cmpxchg64 (ptr, o, n) cmpxchg64_local((ptr), (o), (n))
Quoted 5 lines
arch/sparc/include/asm/cmpxchg_32.h __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size) · line 77
Quoted 1 line
arch/sparc/include/asm/cmpxchg_32.h +0
-0#endif /* __ARCH_SPARC_CMPXCHG__ */ but it's wrong.
cmpxchg64_local()is only atomic on the current cpu so using it for plaincmpxchg64()is not going to work.
Yeah, I was concerned about that. My bad.
Unfortunately I don't know enough about sparc to provide a better solution. Consider this a problem report, then.
Guenter
David Miller
maintainerFrom: Guenter Roeck <[email protected]>
Date: Wed, 27 Sep 2017 21:55:50 -0700
Quoted 27 lines · David Miller
Quoted 14 lines
From: Guenter Roeck <[email protected]>
Date: Sun, 24 Sep 2017 10:29:31 -0700Quoted 9 lines
Fix the following build error, seen when building
sparc32:allmodconfig.
drivers/net/ethernet/intel/i40e/i40e_ethtool.c:
In function 'i40e_set_priv_flags':drivers/net/ethernet/intel/i40e/i40e_ethtool.c:4150:2: error:
implicit declaration of function 'cmpxchg64'Signed-off-by Guenter Roeck <[email protected]>That fixes the build:
Quoted 11 lines
Quoted 8 lines
(quoted diff) +1
-0@@ -72,5 +72,6 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size) ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\ (unsigned long)(n), sizeof(*(ptr)))) #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), #(o), (n)) +#define cmpxchg64(ptr, o, n) cmpxchg64_local((ptr), (o), (n))#endif /* __ARCH_SPARC_CMPXCHG__ */but it's wrong.
cmpxchg64_local()is only atomic on the current cpu so using it for plaincmpxchg64()is not going to work.
Quoted 5 lines
Yeah, I was concerned about that. My bad.
Unfortunately I don't know enough about sparc to provide a better solution.
Consider this a problem report, then.
I'll see what I can do. Something like this:
arch/sparc/include/asm/cmpxchg_32.h +2 -0
@@ -62,6 +62,8 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size) (unsigned long)_n_, sizeof(*(ptr))); \ }) +extern u64 cmpxchg64 (u64 *ptr,u64 old,u64 new); +#include <asm-generic/cmpxchg-local.h> /*
arch/sparc/lib/atomic32.c +14 -0
@@ -172,6 +172,20 @@ unsigned long __cmpxchg_u32(volatile u32 *ptr, u32 old, u32 new) }EXPORT_SYMBOL (__cmpxchg_u32); +u64 cmpxchg64 (u64 *ptr,u64 old,u64 new) +{ +unsigned long flags; +u64 prev; + +spin_lock_irqsave (ATOMIC_HASH (ptr), flags); +if ((prev = *ptr) = old) + *ptr = new; +spin_unlock_irqrestore (ATOMIC_HASH (ptr), flags); + +return prev; +} +EXPORT_SYMBOL (cmpxchg64); +unsigned long __xchg_u32 (volatile u32 *ptr,u32 new) {unsigned long flags;