linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: "Chen Gang" <gang.chen@asianux.com>, "Jörn Engel" <joern@logfs.org>
Cc: Chris Metcalf <cmetcalf@tilera.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linux-Arch <linux-arch@vger.kernel.org>,
	Paul Gortmaker <paul.gortmaker@windriver.com>
Subject: Re: [PATCH] arch: tile: include: asm: add cmpxchg64() definition
Date: Fri, 28 Jun 2013 17:09:41 +0200	[thread overview]
Message-ID: <20130628150941.GA22767@linux-mips.org> (raw)
In-Reply-To: <51CCEC27.8050508@asianux.com>

On Fri, Jun 28, 2013 at 09:51:35AM +0800, Chen Gang wrote:

> Need add cmpxchg64(), or will cause compiling issue.
> 
> Just define it as cmpxchg(), since cmpxchg() can support 8 bytes.
> 
> The related error (with allmodconfig):
> 
>   drivers/block/blockconsole.c: In function ‘bcon_advance_console_bytes’:
>   drivers/block/blockconsole.c:164:2: error: implicit declaration of function ‘cmpxchg64’ [-Werror=implicit-function-declaration]
> 
> Signed-off-by: Chen Gang <gang.chen@asianux.com>
> ---
>  arch/tile/include/asm/cmpxchg.h |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/tile/include/asm/cmpxchg.h b/arch/tile/include/asm/cmpxchg.h
> index 276f067..7688c28 100644
> --- a/arch/tile/include/asm/cmpxchg.h
> +++ b/arch/tile/include/asm/cmpxchg.h
> @@ -68,6 +68,8 @@ extern unsigned long __cmpxchg_called_with_bad_pointer(void);
>  
>  #define tas(ptr) (xchg((ptr), 1))
>  
> +#define cmpxchg64(ptr, o, n)		cmpxchg((ptr), (o), (n))

that's broken.  cmpxchg64 is suposed to work on 64 bit operands ONLY.  This
definition (used by MIPS and Alpha) will work properly:

#define cmpxchg64(ptr, o, n)                                            \
({                                                                      \
	BUILD_BUG_ON(sizeof(*(ptr)) != 8);                              \
	cmpxchg((ptr), (o), (n));                                       \
})

This should cure blockconsole on Tile but not on MIPS.

struct blockconsole {
...
           u64 console_bytes;
...
};

static void bcon_advance_console_bytes(struct blockconsole *bc, int bytes)
{
	u64 old, new;
	...
	} while (cmpxchg64(&bc->console_bytes, old, new) != old);
}

So it's using cmpxchg64() to operate on 64 bit objects - but that's not
going to work on every architecture.  Many 32 bit architectures only
provide atomic operations that operate on 32 bit quantities.

  Ralf

  reply	other threads:[~2013-06-28 15:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <51CA6D21.3090901@asianux.com>
     [not found] ` <51CC492C.1040105@tilera.com>
     [not found]   ` <51CCD891.8000806@asianux.com>
2013-06-28  1:51     ` [PATCH] arch: tile: include: asm: add cmpxchg64() definition Chen Gang
2013-06-28 15:09       ` Ralf Baechle [this message]
2013-07-01  2:08         ` Chen Gang
2013-07-01  2:08           ` Chen Gang
2013-07-01  2:21           ` [PATCH v2] " Chen Gang
2013-07-17 16:46             ` Chris Metcalf
2013-07-17 16:46               ` Chris Metcalf
2013-07-18  0:02               ` Chen Gang

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=20130628150941.GA22767@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=cmetcalf@tilera.com \
    --cc=gang.chen@asianux.com \
    --cc=joern@logfs.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul.gortmaker@windriver.com \
    /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 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).