* [PATCH] arch: tile: include: asm: add cmpxchg64() definition [not found] ` <51CCD891.8000806@asianux.com> @ 2013-06-28 1:51 ` Chen Gang 2013-06-28 15:09 ` Ralf Baechle 0 siblings, 1 reply; 8+ messages in thread From: Chen Gang @ 2013-06-28 1:51 UTC (permalink / raw) To: Chris Metcalf; +Cc: linux-kernel@vger.kernel.org, Linux-Arch 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)) + #endif /* __ASSEMBLY__ */ #endif /* _ASM_TILE_CMPXCHG_H */ -- 1.7.7.6 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] arch: tile: include: asm: add cmpxchg64() definition 2013-06-28 1:51 ` [PATCH] arch: tile: include: asm: add cmpxchg64() definition Chen Gang @ 2013-06-28 15:09 ` Ralf Baechle 2013-07-01 2:08 ` Chen Gang 0 siblings, 1 reply; 8+ messages in thread From: Ralf Baechle @ 2013-06-28 15:09 UTC (permalink / raw) To: Chen Gang, Jörn 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. > > 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] arch: tile: include: asm: add cmpxchg64() definition 2013-06-28 15:09 ` Ralf Baechle @ 2013-07-01 2:08 ` Chen Gang 2013-07-01 2:08 ` Chen Gang 2013-07-01 2:21 ` [PATCH v2] " Chen Gang 0 siblings, 2 replies; 8+ messages in thread From: Chen Gang @ 2013-07-01 2:08 UTC (permalink / raw) To: Ralf Baechle Cc: Jörn Engel, Chris Metcalf, linux-kernel@vger.kernel.org, Linux-Arch, Paul Gortmaker Firstly thank you very much for replying quickly with details. On 06/28/2013 11:09 PM, Ralf Baechle wrote: > 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: > Oh, really it is. thanks. > #define cmpxchg64(ptr, o, n) \ > ({ \ > BUILD_BUG_ON(sizeof(*(ptr)) != 8); \ > cmpxchg((ptr), (o), (n)); \ > }) > I should follow it to send patch v2, thanks. > 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. > I guess your meaning is: cmpxchg64() should be an atomic operation. but on some of 32-bit architectures, they don't implement it as atomic (no lock protected, at least). it may cause issue on these 32-bit architectures. Is it correct ? If it is correct, I should continue to try to fix it. Thanks. -- Chen Gang ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] arch: tile: include: asm: add cmpxchg64() definition 2013-07-01 2:08 ` Chen Gang @ 2013-07-01 2:08 ` Chen Gang 2013-07-01 2:21 ` [PATCH v2] " Chen Gang 1 sibling, 0 replies; 8+ messages in thread From: Chen Gang @ 2013-07-01 2:08 UTC (permalink / raw) To: Ralf Baechle Cc: Jörn Engel, Chris Metcalf, linux-kernel@vger.kernel.org, Linux-Arch, Paul Gortmaker Firstly thank you very much for replying quickly with details. On 06/28/2013 11:09 PM, Ralf Baechle wrote: > 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: > Oh, really it is. thanks. > #define cmpxchg64(ptr, o, n) \ > ({ \ > BUILD_BUG_ON(sizeof(*(ptr)) != 8); \ > cmpxchg((ptr), (o), (n)); \ > }) > I should follow it to send patch v2, thanks. > 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. > I guess your meaning is: cmpxchg64() should be an atomic operation. but on some of 32-bit architectures, they don't implement it as atomic (no lock protected, at least). it may cause issue on these 32-bit architectures. Is it correct ? If it is correct, I should continue to try to fix it. Thanks. -- Chen Gang ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] arch: tile: include: asm: add cmpxchg64() definition 2013-07-01 2:08 ` Chen Gang 2013-07-01 2:08 ` Chen Gang @ 2013-07-01 2:21 ` Chen Gang 2013-07-17 16:46 ` Chris Metcalf 1 sibling, 1 reply; 8+ messages in thread From: Chen Gang @ 2013-07-01 2:21 UTC (permalink / raw) To: Ralf Baechle Cc: Jörn Engel, Chris Metcalf, linux-kernel@vger.kernel.org, Linux-Arch, Paul Gortmaker Need add cmpxchg64(), or will cause compiling issue. Need define it as cmpxchg() only for 64-bit operation, 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 | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/arch/tile/include/asm/cmpxchg.h b/arch/tile/include/asm/cmpxchg.h index 276f067..1da5bfb 100644 --- a/arch/tile/include/asm/cmpxchg.h +++ b/arch/tile/include/asm/cmpxchg.h @@ -68,6 +68,12 @@ extern unsigned long __cmpxchg_called_with_bad_pointer(void); #define tas(ptr) (xchg((ptr), 1)) +#define cmpxchg64(ptr, o, n) \ +({ \ + BUILD_BUG_ON(sizeof(*(ptr)) != 8); \ + cmpxchg((ptr), (o), (n)); \ +}) + #endif /* __ASSEMBLY__ */ #endif /* _ASM_TILE_CMPXCHG_H */ -- 1.7.7.6 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] arch: tile: include: asm: add cmpxchg64() definition 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 0 siblings, 2 replies; 8+ messages in thread From: Chris Metcalf @ 2013-07-17 16:46 UTC (permalink / raw) To: Chen Gang Cc: Ralf Baechle, Jörn Engel, linux-kernel@vger.kernel.org, Linux-Arch, Paul Gortmaker On 6/30/2013 10:21 PM, Chen Gang wrote: > Need add cmpxchg64(), or will cause compiling issue. > > Need define it as cmpxchg() only for 64-bit operation, 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> Thanks, taken into the tile tree. -- Chris Metcalf, Tilera Corp. http://www.tilera.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] arch: tile: include: asm: add cmpxchg64() definition 2013-07-17 16:46 ` Chris Metcalf @ 2013-07-17 16:46 ` Chris Metcalf 2013-07-18 0:02 ` Chen Gang 1 sibling, 0 replies; 8+ messages in thread From: Chris Metcalf @ 2013-07-17 16:46 UTC (permalink / raw) To: Chen Gang Cc: Ralf Baechle, Jörn Engel, linux-kernel@vger.kernel.org, Linux-Arch, Paul Gortmaker On 6/30/2013 10:21 PM, Chen Gang wrote: > Need add cmpxchg64(), or will cause compiling issue. > > Need define it as cmpxchg() only for 64-bit operation, 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> Thanks, taken into the tile tree. -- Chris Metcalf, Tilera Corp. http://www.tilera.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] arch: tile: include: asm: add cmpxchg64() definition 2013-07-17 16:46 ` Chris Metcalf 2013-07-17 16:46 ` Chris Metcalf @ 2013-07-18 0:02 ` Chen Gang 1 sibling, 0 replies; 8+ messages in thread From: Chen Gang @ 2013-07-18 0:02 UTC (permalink / raw) To: Chris Metcalf Cc: Ralf Baechle, Jörn Engel, linux-kernel@vger.kernel.org, Linux-Arch, Paul Gortmaker On 07/18/2013 12:46 AM, Chris Metcalf wrote: > On 6/30/2013 10:21 PM, Chen Gang wrote: >> Need add cmpxchg64(), or will cause compiling issue. >> >> Need define it as cmpxchg() only for 64-bit operation, 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> > > Thanks, taken into the tile tree. > Thank you too. :-) -- Chen Gang ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-07-18 0:03 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[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
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
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).