[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8yazkrjkuo3.fsf@huya.qualcomm.com>
Date: Sun, 02 Jan 2011 10:49:32 -0800
From: David Brown <davidb@...eaurora.org>
To: Pavel Machek <pavel@....cz>
Cc: Nicolas Pitre <nico@...xnic.net>,
Stephen Boyd <sboyd@...eaurora.org>,
Greg Kroah-Hartman <gregkh@...e.de>,
linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
Tony Lindgren <tony@...mide.com>,
Arnd Bergmann <arnd@...db.de>,
Daniel Walker <dwalker@...eaurora.org>
Subject: Re: [PATCH 1/3] hvc_dcc: Fix bad code generation by marking assembly volatile
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.
--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists