lkml.org 
[lkml]   [2011]   [Jan]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/3] hvc_dcc: Fix bad code generation by marking assembly volatile
On Sun 2011-01-02 10:49:32, David Brown wrote:
> On Sun, Jan 02 2011, Pavel Machek wrote:
>
> >> > diff --git a/drivers/char/hvc_dcc.c b/drivers/char/hvc_dcc.c
> >> > index 6470f63..155ec10 100644
> >> > --- a/drivers/char/hvc_dcc.c
> >> > +++ b/drivers/char/hvc_dcc.c
> >> > @@ -33,8 +33,7 @@
> >> > static inline u32 __dcc_getstatus(void)
> >> > {
> >> > u32 __ret;
> >> > -
> >> > - asm("mrc p14, 0, %0, c0, c1, 0 @ read comms ctrl reg"
> >> > + asm volatile("mrc p14, 0, %0, c0, c1, 0 @ read comms ctrl reg"
> >> > : "=r" (__ret) : : "cc");
> >> >
> >> > return __ret;
> >
> > Is volatile needed here? If __dcc_getstatus() return value is
> > discarded, we want assembly discarded, right?
>
> That's not really the issue being fixed. Without the volatile, the
> compiler is free to cache and reuse a previously loaded status value.
> It is important that the status be read each time.
>
> I don't think there is a way of indicating that assembly needs to happen
> for each use, but that it is OK to discard if the value isn't used.
> 'volatile' is a bit overloaded.

Ok, thanks for explanation.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


\
 
 \ /
  Last update: 2011-01-03 06:53    [W:0.051 / U:0.912 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site