* use of volatile in iounmap()?
@ 2008-03-28 20:34 Sam Ravnborg
2008-03-28 20:51 ` H. Peter Anvin
2008-03-28 21:17 ` Al Viro
0 siblings, 2 replies; 5+ messages in thread
From: Sam Ravnborg @ 2008-03-28 20:34 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar
While reviewing some CAN driver I stumbled on iounmap
which has following prototype on x86:
extern void iounmap(volatile void __iomem *addr);
I argued that the driver should not use volatile
but then I cannot explain why the argument to
iounmap takes a volatile.
The same goes for many other functions in
the io*.h headers.
Grepping the other archs they mostly follow
same pattern.
Can anyone explain the rational for volatile in this case.
Thanks,
Sam
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: use of volatile in iounmap()?
2008-03-28 20:34 use of volatile in iounmap()? Sam Ravnborg
@ 2008-03-28 20:51 ` H. Peter Anvin
2008-03-28 21:04 ` Sam Ravnborg
2008-03-28 21:17 ` Al Viro
1 sibling, 1 reply; 5+ messages in thread
From: H. Peter Anvin @ 2008-03-28 20:51 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: LKML, Ingo Molnar
Sam Ravnborg wrote:
> While reviewing some CAN driver I stumbled on iounmap
> which has following prototype on x86:
>
> extern void iounmap(volatile void __iomem *addr);
>
> I argued that the driver should not use volatile
> but then I cannot explain why the argument to
> iounmap takes a volatile.
>
> The same goes for many other functions in
> the io*.h headers.
>
> Grepping the other archs they mostly follow
> same pattern.
>
> Can anyone explain the rational for volatile in this case.
>
Yes. The use of volatile in a function prototype like this means that
it is valid to pass a volatile pointer to that function -- in other
words, we're telling gcc that we're not going to do anything with the
pointer that is invalid for a volatile pointer.
A lot of the "volatile considered harmful" stuff that has been bandied
about is explicitly about marking *data* items volatile (it does have
its uses, but it's easy to get wrong); Linus has explicitly made the
distinction between volatile *data* and volatile *operations*.
-hpa
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: use of volatile in iounmap()?
2008-03-28 20:51 ` H. Peter Anvin
@ 2008-03-28 21:04 ` Sam Ravnborg
2008-03-28 21:07 ` H. Peter Anvin
0 siblings, 1 reply; 5+ messages in thread
From: Sam Ravnborg @ 2008-03-28 21:04 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: LKML, Ingo Molnar
On Fri, Mar 28, 2008 at 01:51:12PM -0700, H. Peter Anvin wrote:
> Sam Ravnborg wrote:
> >While reviewing some CAN driver I stumbled on iounmap
> >which has following prototype on x86:
> >
> >extern void iounmap(volatile void __iomem *addr);
> >
> >I argued that the driver should not use volatile
> >but then I cannot explain why the argument to
> >iounmap takes a volatile.
> >
> >The same goes for many other functions in
> >the io*.h headers.
> >
> >Grepping the other archs they mostly follow
> >same pattern.
> >
> >Can anyone explain the rational for volatile in this case.
> >
>
> Yes. The use of volatile in a function prototype like this means that
> it is valid to pass a volatile pointer to that function -- in other
> words, we're telling gcc that we're not going to do anything with the
> pointer that is invalid for a volatile pointer.
If I understand you correct then it is then not wrong to say
that we have the argument volatile to avoid warnings from gcc
when we pass a volatile pointer.
And then having the pointer marked volatile put a few restrictions
on iounmap().
>
> A lot of the "volatile considered harmful" stuff that has been bandied
> about is explicitly about marking *data* items volatile (it does have
> its uses, but it's easy to get wrong); Linus has explicitly made the
> distinction between volatile *data* and volatile *operations*.
Yes - but unfortunately the volatile-considered-harmful.txt
does many deal with the data part.
Thanks,
Sam
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: use of volatile in iounmap()?
2008-03-28 21:04 ` Sam Ravnborg
@ 2008-03-28 21:07 ` H. Peter Anvin
0 siblings, 0 replies; 5+ messages in thread
From: H. Peter Anvin @ 2008-03-28 21:07 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: LKML, Ingo Molnar
Sam Ravnborg wrote:
>>>
>> Yes. The use of volatile in a function prototype like this means that
>> it is valid to pass a volatile pointer to that function -- in other
>> words, we're telling gcc that we're not going to do anything with the
>> pointer that is invalid for a volatile pointer.
> If I understand you correct then it is then not wrong to say
> that we have the argument volatile to avoid warnings from gcc
> when we pass a volatile pointer.
>
> And then having the pointer marked volatile put a few restrictions
> on iounmap().
Correct.
>> A lot of the "volatile considered harmful" stuff that has been bandied
>> about is explicitly about marking *data* items volatile (it does have
>> its uses, but it's easy to get wrong); Linus has explicitly made the
>> distinction between volatile *data* and volatile *operations*.
>
> Yes - but unfortunately the volatile-considered-harmful.txt
> does many deal with the data part.
Yes, it does.
-hpa
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: use of volatile in iounmap()?
2008-03-28 20:34 use of volatile in iounmap()? Sam Ravnborg
2008-03-28 20:51 ` H. Peter Anvin
@ 2008-03-28 21:17 ` Al Viro
1 sibling, 0 replies; 5+ messages in thread
From: Al Viro @ 2008-03-28 21:17 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: LKML, Ingo Molnar
On Fri, Mar 28, 2008 at 09:34:28PM +0100, Sam Ravnborg wrote:
> While reviewing some CAN driver I stumbled on iounmap
> which has following prototype on x86:
>
> extern void iounmap(volatile void __iomem *addr);
>
> I argued that the driver should not use volatile
> but then I cannot explain why the argument to
> iounmap takes a volatile.
>
> The same goes for many other functions in
> the io*.h headers.
>
> Grepping the other archs they mostly follow
> same pattern.
>
> Can anyone explain the rational for volatile in this case.
"Passing a pointer to volatile is allowed, along with passing pointers
to unqualified".
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-03-28 21:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-28 20:34 use of volatile in iounmap()? Sam Ravnborg
2008-03-28 20:51 ` H. Peter Anvin
2008-03-28 21:04 ` Sam Ravnborg
2008-03-28 21:07 ` H. Peter Anvin
2008-03-28 21:17 ` Al Viro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox