diff mbox series

[v3] sparc: Provide cmpxchg64 for 32-bit builds

Message ID 1509979305-11791-1-git-send-email-linux@roeck-us.net
State Not Applicable
Delegated to: David Miller
Headers show
Series [v3] sparc: Provide cmpxchg64 for 32-bit builds | expand

Commit Message

Guenter Roeck Nov. 6, 2017, 2:41 p.m. UTC
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>
---
v3: Drop extern from cmpxchg64 declaration in include file
v2: Actually implement cmpxchg64 with code snippet provided by Dave Miller
    Note: I am aware that this doesn't pass checkpatch; I found it more
    important to be in line with __cmpxchg_u32().

 arch/sparc/include/asm/cmpxchg_32.h |  2 ++
 arch/sparc/lib/atomic32.c           | 14 ++++++++++++++
 2 files changed, 16 insertions(+)

Comments

David Miller Nov. 9, 2017, 6:28 a.m. UTC | #1
From: Guenter Roeck <linux@roeck-us.net>
Date: Mon,  6 Nov 2017 06:41:45 -0800

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

Guenter, are you really not seeing this commit which has been
in my sparc GIT tree for a while?

commit 23198ddffb6cddb5d5824230af4dd4b46e4046a4
Author: David S. Miller <davem@davemloft.net>
Date:   Wed Sep 27 22:38:19 2017 -0700

    sparc32: Add cmpxchg64().
    
    This fixes the build with i40e driver enabled.
    
    Reported-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: David S. Miller <davem@davemloft.net>

diff --git a/arch/sparc/include/asm/cmpxchg_32.h b/arch/sparc/include/asm/cmpxchg_32.h
index 83ffb83c5397..a0101a58fd3f 100644
--- a/arch/sparc/include/asm/cmpxchg_32.h
+++ b/arch/sparc/include/asm/cmpxchg_32.h
@@ -62,6 +62,9 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size)
 			(unsigned long)_n_, sizeof(*(ptr)));		\
 })
 
+u64 __cmpxchg_u64(u64 *ptr, u64 old, u64 new);
+#define cmpxchg64(ptr, old, new)	__cmpxchg_u64(ptr, old, new)
+
 #include <asm-generic/cmpxchg-local.h>
 
 /*
diff --git a/arch/sparc/lib/atomic32.c b/arch/sparc/lib/atomic32.c
index 2c373329d5cb..ddacb5aeb424 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 __cmpxchg_u64(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(__cmpxchg_u64);
+
 unsigned long __xchg_u32(volatile u32 *ptr, u32 new)
 {
 	unsigned long flags;
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Guenter Roeck Nov. 9, 2017, 3:53 p.m. UTC | #2
On Thu, Nov 09, 2017 at 03:28:52PM +0900, David Miller wrote:
> From: Guenter Roeck <linux@roeck-us.net>
> Date: Mon,  6 Nov 2017 06:41:45 -0800
> 
> > 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>
> 
> Guenter, are you really not seeing this commit which has been
> in my sparc GIT tree for a while?
> 
Dave,

At least as of yesterday, the patch had not found its way into mainline.

I am running kernel build tests in my spare time, as community service.
I do spend time before I submit a report or a proposed patch trying to
find if the problem or its fix was already posted, just to avoid the
"you dummy, this was already fixed" type feedback. However, I typically
don't repeat that if it appears that the original report or submission
was ignored. I just don't have the time to do that.

So, no, I did not see the patch in your tree. Sorry for the noise.
I'll refrain from reporting problems on sparc to avoid such noise
in the future. I'll definitely no longer send out reminders.

Guenter
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/arch/sparc/include/asm/cmpxchg_32.h b/arch/sparc/include/asm/cmpxchg_32.h
index 83ffb83c5397..01bb66b5d125 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)));		\
 })
 
+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 2c373329d5cb..41601eb540e7 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;