From: Joe Perches <joe@perches.com>
To: Guenter Roeck <linux@roeck-us.net>,
"David S . Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] sparc: Provide cmpxchg64 for 32-bit builds
Date: Thu, 26 Oct 2017 04:53:52 +0000 [thread overview]
Message-ID: <1508993632.10651.19.camel@perches.com> (raw)
In-Reply-To: <1508986312-32081-1-git-send-email-linux@roeck-us.net>
On Wed, 2017-10-25 at 19:51 -0700, Guenter Roeck wrote:
> 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>
> ---
> 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(+)
>
> diff --git a/arch/sparc/include/asm/cmpxchg_32.h b/arch/sparc/include/asm/cmpxchg_32.h
> index 83ffb83c5397..7f95d3ca20e2 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);
This extern is unusual style for sparc function declarations.
> +
> #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;
WARNING: multiple messages have this Message-ID (diff)
From: Joe Perches <joe@perches.com>
To: Guenter Roeck <linux@roeck-us.net>,
"David S . Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] sparc: Provide cmpxchg64 for 32-bit builds
Date: Wed, 25 Oct 2017 21:53:52 -0700 [thread overview]
Message-ID: <1508993632.10651.19.camel@perches.com> (raw)
In-Reply-To: <1508986312-32081-1-git-send-email-linux@roeck-us.net>
On Wed, 2017-10-25 at 19:51 -0700, Guenter Roeck wrote:
> 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>
> ---
> 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(+)
>
> diff --git a/arch/sparc/include/asm/cmpxchg_32.h b/arch/sparc/include/asm/cmpxchg_32.h
> index 83ffb83c5397..7f95d3ca20e2 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);
This extern is unusual style for sparc function declarations.
> +
> #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;
next prev parent reply other threads:[~2017-10-26 4:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-26 2:51 [PATCH v2] sparc: Provide cmpxchg64 for 32-bit builds Guenter Roeck
2017-10-26 2:51 ` Guenter Roeck
2017-10-26 4:53 ` Joe Perches [this message]
2017-10-26 4:53 ` Joe Perches
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=1508993632.10651.19.camel@perches.com \
--to=joe@perches.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=sparclinux@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.