Recommended functions for accessing internal registers

Fortini Matteo matteo.fortini at
Thu Dec 3 22:16:05 EST 2009

I'm on an embedded system, so every resource counts.
One of the biggest impacts is when writing to a communication/memory 
access FIFO or reading/writing configurations.
In these cases, I'd just need to make sure that there's no I/O 
reordering and/or subsequent r/w are not optimized away, I believe.

Should I switch to the deprecated "volatile" attribute?

Thank you.


Il 02/12/2009 21.57, Benjamin Herrenschmidt ha scritto:
> On Tue, 2009-12-01 at 17:44 +0100, Fortini Matteo wrote:
>> I see that throughout the kernel source, internal PPC registers are
>> accessed through [in|out]_be[32|16|8]() functions. However, they are
>> translated into 3 inline assembly instructions, one of which is an
>> isync, which has a huge performance hit.
>> I tried using readl_be() which seems to be the right function according
>> to the Documentation/ dir, but it is translated directly to in_be32(),
>> so no luck.
>> Is it really necessary to use all those instructions? I know I could use
>> a (volatile u32 *) variable to avoid subsequent read/writes to be
>> optimized out, but it seems to be a deprecated use.
> There are good reasons why the accessors contain those barriers. What
> are you doing that would be performance critical enough for those to be
> a problem ?
> Cheers,
> Ben.

More information about the Linuxppc-dev mailing list