[U-Boot] [PATCH v2] arm: Switch to -mno-unaligned-access when supported by the compiler

Måns Rullgård mans at mansr.com
Tue Feb 11 19:21:26 CET 2014


Wolfgang Denk <wd at denx.de> writes:

> Dear Måns Rullgård,
>
> In message <yw1xfvnpaclm.fsf at unicorn.mansr.com> you wrote:
>>
>> > With application code you don't really care whether a variable is
>> > read/written in one piece or broken down into several smaller
>> > reads/writes - except when you notice that performance suffers.
>> >
>> > When accessing hardware, it often makes a fundamental difference
>> > whether you access a device register with it's correct size or not.
>> > Usually breaking down an access into smaller ones results in crashes
>> > or incorrect data or other errors.
>> 
>> I'm well aware of this, but it has nothing to do with the issue at hand.
>
> This is by your definition, or based on which exact rationale?
>
>> Device registers are always aligned.  In properly written code these are
>> accessed using pointers the compiler knows to be aligned and thus does
>> the right thing.
>
> Maybe the device registers you have seen so far have always been
> perfectly aligned.  Lucky you.  Note that there are a number of
> designs around (that I do not hesitate to call broken) which have
> such properties.  And when we include external hardware into the
> discussion like PCI attached devices or customer-designed FPGAs,
> it becomes even more "interesting".

Please explain how you would access an unaligned register from a CPU
that doesn't allow unaligned accesses.  Clearly such a combination of
hardware can never work, so there is no use trying to cater for it in
haphazard ways that end up breaking perfectly normal systems.

-- 
Måns Rullgård
mans at mansr.com


More information about the U-Boot mailing list