From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ralf Baechle Subject: Re: [PATCH] arch: tile: include: asm: add cmpxchg64() definition Date: Fri, 28 Jun 2013 17:09:41 +0200 Message-ID: <20130628150941.GA22767@linux-mips.org> References: <51CA6D21.3090901@asianux.com> <51CC492C.1040105@tilera.com> <51CCD891.8000806@asianux.com> <51CCEC27.8050508@asianux.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Received: from eddie.linux-mips.org ([78.24.191.182]:33480 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750818Ab3F1PJy (ORCPT ); Fri, 28 Jun 2013 11:09:54 -0400 Received: from localhost.localdomain ([127.0.0.1]:56662 "EHLO linux-mips.org" rhost-flags-OK-OK-OK-FAIL) by eddie.linux-mips.org with ESMTP id S6823114Ab3F1PJxoND2q (ORCPT + 1 other); Fri, 28 Jun 2013 17:09:53 +0200 Content-Disposition: inline In-Reply-To: <51CCEC27.8050508@asianux.com> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Chen Gang , =?iso-8859-1?Q?J=F6rn?= Engel Cc: Chris Metcalf , "linux-kernel@vger.kernel.org" , Linux-Arch , Paul Gortmaker On Fri, Jun 28, 2013 at 09:51:35AM +0800, Chen Gang wrote: > Need add cmpxchg64(), or will cause compiling issue. >=20 > Just define it as cmpxchg(), since cmpxchg() can support 8 bytes. >=20 > The related error (with allmodconfig): >=20 > drivers/block/blockconsole.c: In function =E2=80=98bcon_advance_con= sole_bytes=E2=80=99: > drivers/block/blockconsole.c:164:2: error: implicit declaration of = function =E2=80=98cmpxchg64=E2=80=99 [-Werror=3Dimplicit-function-decla= ration] >=20 > Signed-off-by: Chen Gang > --- > arch/tile/include/asm/cmpxchg.h | 2 ++ > 1 files changed, 2 insertions(+), 0 deletions(-) >=20 > 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_poin= ter(void); > =20 > #define tas(ptr) (xchg((ptr), 1)) > =20 > +#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)) !=3D 8); \ cmpxchg((ptr), (o), (n)); \ }) This should cure blockconsole on Tile but not on MIPS. struct blockconsole { =2E.. u64 console_bytes; =2E.. }; static void bcon_advance_console_bytes(struct blockconsole *bc, int byt= es) { u64 old, new; ... } while (cmpxchg64(&bc->console_bytes, old, new) !=3D 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