linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH/RFC] m68k/bitops: Make bitmap data pointer of atomic ops volatile
@ 2011-06-06 20:07 Geert Uytterhoeven
  2011-06-06 20:11 ` Arnd Bergmann
  0 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2011-06-06 20:07 UTC (permalink / raw)
  To: linux-m68k, Akinobu Mita, Arnd Bergmann
  Cc: linux-kernel, Ben Hutchings, Geert Uytterhoeven

This fixes a.o.

drivers/ide/ide-io.c: In function ‘ide_lock_host’:
drivers/ide/ide-io.c:415: warning: passing argument 2 of ‘__constant_test_and_set_bit’ discards qualifiers from pointer target type
drivers/ide/ide-io.c:415: warning: passing argument 2 of ‘__generic_test_and_set_bit’ discards qualifiers from pointer target type

Suggested-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
I'm not 100% sure whether all of these should be volatile.
We're only getting compiler warnings for calls to test_and_set_bit().

 arch/m68k/include/asm/bitops_mm.h |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/arch/m68k/include/asm/bitops_mm.h b/arch/m68k/include/asm/bitops_mm.h
index 89cf5b8..2d31d5f 100644
--- a/arch/m68k/include/asm/bitops_mm.h
+++ b/arch/m68k/include/asm/bitops_mm.h
@@ -27,7 +27,8 @@
 
 #define __test_and_set_bit(nr,vaddr) test_and_set_bit(nr,vaddr)
 
-static inline int __constant_test_and_set_bit(int nr, unsigned long *vaddr)
+static inline int __constant_test_and_set_bit(int nr,
+					      volatile unsigned long *vaddr)
 {
 	char *p = (char *)vaddr + (nr ^ 31) / 8;
 	char retval;
@@ -39,7 +40,8 @@ static inline int __constant_test_and_set_bit(int nr, unsigned long *vaddr)
 	return retval;
 }
 
-static inline int __generic_test_and_set_bit(int nr, unsigned long *vaddr)
+static inline int __generic_test_and_set_bit(int nr,
+					     volatile unsigned long *vaddr)
 {
 	char retval;
 
@@ -76,7 +78,8 @@ static inline void __generic_set_bit(int nr, volatile unsigned long *vaddr)
 
 #define __test_and_clear_bit(nr,vaddr) test_and_clear_bit(nr,vaddr)
 
-static inline int __constant_test_and_clear_bit(int nr, unsigned long *vaddr)
+static inline int __constant_test_and_clear_bit(int nr,
+						volatile unsigned long *vaddr)
 {
 	char *p = (char *)vaddr + (nr ^ 31) / 8;
 	char retval;
@@ -88,7 +91,8 @@ static inline int __constant_test_and_clear_bit(int nr, unsigned long *vaddr)
 	return retval;
 }
 
-static inline int __generic_test_and_clear_bit(int nr, unsigned long *vaddr)
+static inline int __generic_test_and_clear_bit(int nr,
+					       volatile unsigned long *vaddr)
 {
 	char retval;
 
@@ -131,7 +135,8 @@ static inline void __generic_clear_bit(int nr, volatile unsigned long *vaddr)
 #define __test_and_change_bit(nr,vaddr) test_and_change_bit(nr,vaddr)
 #define __change_bit(nr,vaddr) change_bit(nr,vaddr)
 
-static inline int __constant_test_and_change_bit(int nr, unsigned long *vaddr)
+static inline int __constant_test_and_change_bit(int nr,
+						 volatile unsigned long *vaddr)
 {
 	char *p = (char *)vaddr + (nr ^ 31) / 8;
 	char retval;
@@ -143,7 +148,8 @@ static inline int __constant_test_and_change_bit(int nr, unsigned long *vaddr)
 	return retval;
 }
 
-static inline int __generic_test_and_change_bit(int nr, unsigned long *vaddr)
+static inline int __generic_test_and_change_bit(int nr,
+						volatile unsigned long *vaddr)
 {
 	char retval;
 
@@ -158,14 +164,14 @@ static inline int __generic_test_and_change_bit(int nr, unsigned long *vaddr)
    __constant_change_bit(nr, vaddr) : \
    __generic_change_bit(nr, vaddr))
 
-static inline void __constant_change_bit(int nr, unsigned long *vaddr)
+static inline void __constant_change_bit(int nr, volatile unsigned long *vaddr)
 {
 	char *p = (char *)vaddr + (nr ^ 31) / 8;
 	__asm__ __volatile__ ("bchg %1,%0"
 			: "+m" (*p) : "di" (nr & 7));
 }
 
-static inline void __generic_change_bit(int nr, unsigned long *vaddr)
+static inline void __generic_change_bit(int nr, volatile unsigned long *vaddr)
 {
 	__asm__ __volatile__ ("bfchg %1{%0:#1}"
 			: : "d" (nr^31), "o" (*vaddr) : "memory");
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH/RFC] m68k/bitops: Make bitmap data pointer of atomic ops volatile
  2011-06-06 20:07 [PATCH/RFC] m68k/bitops: Make bitmap data pointer of atomic ops volatile Geert Uytterhoeven
@ 2011-06-06 20:11 ` Arnd Bergmann
  2011-06-07  7:09   ` Geert Uytterhoeven
  0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2011-06-06 20:11 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-m68k, Akinobu Mita, linux-kernel, Ben Hutchings

On Monday 06 June 2011 22:07:53 Geert Uytterhoeven wrote:
> 
> This fixes a.o.
> 
> drivers/ide/ide-io.c: In function ‘ide_lock_host’:
> drivers/ide/ide-io.c:415: warning: passing argument 2 of ‘__constant_test_and_set_bit’ discards qualifiers from pointer target type
> drivers/ide/ide-io.c:415: warning: passing argument 2 of ‘__generic_test_and_set_bit’ discards qualifiers from pointer target type
> 
> Suggested-by: Ben Hutchings <ben@decadent.org.uk>
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

I think the correct fix would be to mark the variable not volatile, as it
clearly has no business be marked as such. That doesn't mean your patch
is wrong, though. It probably doesn't hurt to do both.

	Arnd

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH/RFC] m68k/bitops: Make bitmap data pointer of atomic ops volatile
  2011-06-06 20:11 ` Arnd Bergmann
@ 2011-06-07  7:09   ` Geert Uytterhoeven
  2011-06-07 11:22     ` Arnd Bergmann
  0 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2011-06-07  7:09 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-m68k, Akinobu Mita, linux-kernel, Ben Hutchings, linux-ide,
	dri-devel

On Mon, Jun 6, 2011 at 22:11, Arnd Bergmann <arnd@arndb.de> wrote:
> On Monday 06 June 2011 22:07:53 Geert Uytterhoeven wrote:
>>
>> This fixes a.o.
>>
>> drivers/ide/ide-io.c: In function ‘ide_lock_host’:
>> drivers/ide/ide-io.c:415: warning: passing argument 2 of ‘__constant_test_and_set_bit’ discards qualifiers from pointer target type
>> drivers/ide/ide-io.c:415: warning: passing argument 2 of ‘__generic_test_and_set_bit’ discards qualifiers from pointer target type
>>
>> Suggested-by: Ben Hutchings <ben@decadent.org.uk>
>> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
>
> I think the correct fix would be to mark the variable not volatile, as it
> clearly has no business be marked as such. That doesn't mean your patch

You mean the host_busy variable in the IDE code?
That would also apply to context_flag in the DRM code:

drivers/gpu/drm/drm_context.c:233: warning: passing argument 2 of
‘__constant_test_and_set_bit’ discards qualifiers from pointer target
type
drivers/gpu/drm/drm_context.c:233: warning: passing argument 2 of
‘__generic_test_and_set_bit’ discards qualifiers from pointer target
type

> is wrong, though. It probably doesn't hurt to do both.

asm-generic/bitops/atomic.h has the volatiles everywhere. That's why
I'm wondering.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH/RFC] m68k/bitops: Make bitmap data pointer of atomic ops volatile
  2011-06-07  7:09   ` Geert Uytterhoeven
@ 2011-06-07 11:22     ` Arnd Bergmann
  2011-06-07 13:35       ` Ben Hutchings
  0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2011-06-07 11:22 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linux-m68k, Akinobu Mita, linux-kernel, Ben Hutchings, linux-ide,
	dri-devel

On Tuesday 07 June 2011, Geert Uytterhoeven wrote:
> You mean the host_busy variable in the IDE code?
> That would also apply to context_flag in the DRM code:
> 
> drivers/gpu/drm/drm_context.c:233: warning: passing argument 2 of
> ‘__constant_test_and_set_bit’ discards qualifiers from pointer target
> type
> drivers/gpu/drm/drm_context.c:233: warning: passing argument 2 of
> ‘__generic_test_and_set_bit’ discards qualifiers from pointer target
> type

Yes, that fits the same category.

> > is wrong, though. It probably doesn't hurt to do both.
> 
> asm-generic/bitops/atomic.h has the volatiles everywhere. That's why
> I'm wondering.

I guess what happened is that some variables are traditionally marked
as volatile although they shouldn't be, and most architectures have
adapted their bitops to make the warnings go away. If you see more
warnings of that kind, it's probably fine to just do the same on m68k.
The volatile modifier doesn't really hurt in this case.

	Arnd

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH/RFC] m68k/bitops: Make bitmap data pointer of atomic ops volatile
  2011-06-07 11:22     ` Arnd Bergmann
@ 2011-06-07 13:35       ` Ben Hutchings
  2011-06-07 13:56         ` Arnd Bergmann
  0 siblings, 1 reply; 6+ messages in thread
From: Ben Hutchings @ 2011-06-07 13:35 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Geert Uytterhoeven, linux-m68k, Akinobu Mita, linux-kernel,
	linux-ide, dri-devel

On Tue, Jun 07, 2011 at 01:22:29PM +0200, Arnd Bergmann wrote:
> On Tuesday 07 June 2011, Geert Uytterhoeven wrote:
> > You mean the host_busy variable in the IDE code?
> > That would also apply to context_flag in the DRM code:
> > 
> > drivers/gpu/drm/drm_context.c:233: warning: passing argument 2 of
> > ‘__constant_test_and_set_bit’ discards qualifiers from pointer target
> > type
> > drivers/gpu/drm/drm_context.c:233: warning: passing argument 2 of
> > ‘__generic_test_and_set_bit’ discards qualifiers from pointer target
> > type
> 
> Yes, that fits the same category.
> 
> > > is wrong, though. It probably doesn't hurt to do both.
> > 
> > asm-generic/bitops/atomic.h has the volatiles everywhere. That's why
> > I'm wondering.
> 
> I guess what happened is that some variables are traditionally marked
> as volatile although they shouldn't be, and most architectures have
> adapted their bitops to make the warnings go away. If you see more
> warnings of that kind, it's probably fine to just do the same on m68k.
> The volatile modifier doesn't really hurt in this case.
 
These operations are required to be atomic and therefore they
must be suitable for use with volatile-qualified variables.

Ben.

-- 
Ben Hutchings
We get into the habit of living before acquiring the habit of thinking.
                                                              - Albert Camus

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH/RFC] m68k/bitops: Make bitmap data pointer of atomic ops volatile
  2011-06-07 13:35       ` Ben Hutchings
@ 2011-06-07 13:56         ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2011-06-07 13:56 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: Geert Uytterhoeven, linux-m68k, Akinobu Mita, linux-kernel,
	linux-ide, dri-devel

On Tuesday 07 June 2011, Ben Hutchings wrote:
> On Tue, Jun 07, 2011 at 01:22:29PM +0200, Arnd Bergmann wrote:

> > I guess what happened is that some variables are traditionally marked
> > as volatile although they shouldn't be, and most architectures have
> > adapted their bitops to make the warnings go away. If you see more
> > warnings of that kind, it's probably fine to just do the same on m68k.
> > The volatile modifier doesn't really hurt in this case.
>  
> These operations are required to be atomic and therefore they
> must be suitable for use with volatile-qualified variables.

As I said, it's not wrong for them to have a volatile qualifier in the
argument list. However, there should also not be the need for the
qualifier in any of the callers, because the bitops only work if
all accesses to the data are done through bitops functions, and that
means that the qualifier on the variable is completely meaningless.

	Arnd

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-06-07 13:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-06 20:07 [PATCH/RFC] m68k/bitops: Make bitmap data pointer of atomic ops volatile Geert Uytterhoeven
2011-06-06 20:11 ` Arnd Bergmann
2011-06-07  7:09   ` Geert Uytterhoeven
2011-06-07 11:22     ` Arnd Bergmann
2011-06-07 13:35       ` Ben Hutchings
2011-06-07 13:56         ` Arnd Bergmann

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