mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sparc: Provide cmpxchg64 for 32-bit builds
@ 2017-09-24 17:29 Guenter Roeck
  2017-09-28  4:38 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Guenter Roeck @ 2017-09-24 17:29 UTC (permalink / raw)
  To: David S . Miller; +Cc: sparclinux, linux-kernel, Guenter Roeck

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 <linux@roeck-us.net>
---
 arch/sparc/include/asm/cmpxchg_32.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/sparc/include/asm/cmpxchg_32.h b/arch/sparc/include/asm/cmpxchg_32.h
index 83ffb83c5397..4b59bf99d2ed 100644
--- a/arch/sparc/include/asm/cmpxchg_32.h
+++ b/arch/sparc/include/asm/cmpxchg_32.h
@@ -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__ */
-- 
2.7.4

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

* Re: [PATCH] sparc: Provide cmpxchg64 for 32-bit builds
  2017-09-24 17:29 [PATCH] sparc: Provide cmpxchg64 for 32-bit builds Guenter Roeck
@ 2017-09-28  4:38 ` David Miller
  2017-09-28  4:55   ` Guenter Roeck
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2017-09-28  4:38 UTC (permalink / raw)
  To: linux; +Cc: sparclinux, linux-kernel

From: Guenter Roeck <linux@roeck-us.net>
Date: Sun, 24 Sep 2017 10:29:31 -0700

> 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 <linux@roeck-us.net>

That fixes the build:

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

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

* Re: [PATCH] sparc: Provide cmpxchg64 for 32-bit builds
  2017-09-28  4:38 ` David Miller
@ 2017-09-28  4:55   ` Guenter Roeck
  2017-09-28  5:28     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Guenter Roeck @ 2017-09-28  4:55 UTC (permalink / raw)
  To: David Miller; +Cc: sparclinux, linux-kernel

On 09/27/2017 09:38 PM, David Miller wrote:
> From: Guenter Roeck <linux@roeck-us.net>
> Date: Sun, 24 Sep 2017 10:29:31 -0700
> 
>> 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 <linux@roeck-us.net>
> 
> That fixes the build:
> 
>> @@ -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.
> 

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

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

* Re: [PATCH] sparc: Provide cmpxchg64 for 32-bit builds
  2017-09-28  4:55   ` Guenter Roeck
@ 2017-09-28  5:28     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-09-28  5:28 UTC (permalink / raw)
  To: linux; +Cc: sparclinux, linux-kernel

From: Guenter Roeck <linux@roeck-us.net>
Date: Wed, 27 Sep 2017 21:55:50 -0700

> On 09/27/2017 09:38 PM, David Miller wrote:
>> From: Guenter Roeck <linux@roeck-us.net>
>> Date: Sun, 24 Sep 2017 10:29:31 -0700
>> 
>>> 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 <linux@roeck-us.net>
>> That fixes the build:
>> 
>>> @@ -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.
>> 
> 
> 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:

diff --git a/arch/sparc/include/asm/cmpxchg_32.h b/arch/sparc/include/asm/cmpxchg_32.h
index 83ffb83..7f95d3c 100644
--- a/arch/sparc/include/asm/cmpxchg_32.h
+++ b/arch/sparc/include/asm/cmpxchg_32.h
@@ -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>
 
 /*
diff --git a/arch/sparc/lib/atomic32.c b/arch/sparc/lib/atomic32.c
index 2c37332..41601eb 100644
--- a/arch/sparc/lib/atomic32.c
+++ b/arch/sparc/lib/atomic32.c
@@ -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;

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

end of thread, other threads:[~2017-09-28  5:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-24 17:29 [PATCH] sparc: Provide cmpxchg64 for 32-bit builds Guenter Roeck
2017-09-28  4:38 ` David Miller
2017-09-28  4:55   ` Guenter Roeck
2017-09-28  5:28     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®