Re: [RFC] [PATCH] Fix b43 driver build for arm

From: Michael Buesch
Date: Mon Feb 18 2008 - 18:06:31 EST


On Monday 18 February 2008 23:53:54 Russell King wrote:
> I get extremely pissed off everytime I have to try to explain random
> alignment issues to people. "It doesn't work like i386 so it must be
> broken" is a rediculous position to take.

I did _not_ ask for a general description of alignment. I did
_just_ ask why ARM is special and why the compiler didn't handle
it there. I do develop code for MIPS, so I do know what alignment is about.

> > Can you _please_ explain what makes ARM so special here?
>
> No because I don't really know.
>
> > Why can't we have an array of this structure on ARM?
> >
> > struct ssb_device_id {
> > __u16 vendor;
>
> 2 bytes
>
> > __u16 coreid;
>
> 2 bytes
>
> > __u8 revision;
>
> 1 byte
>
> > };
>
> and therefore sizeof this structure will be 5 bytes, but because of the
> ABI rules (which are _explicitly_ allowed by the C standard), it'll
> become 8 bytes due to padding afterwards.

So that would be fine. I don't see what would be unaligned then.
Even if it would pad only one byte after the "revision" it would all
be aligned in a natural way.

> At a _guess_ and its only a guess, the linker will enforce this rule
> between compilation units, otherwise the implications are disgusting
> (would probably result in all loads having to be individual byte loads
> and instructions to combine the result - since ARM has strict alignment
> requirements.)

Yeah. As I said. The code does work on MIPS, which has strict alignment
requirements as well.

> What I can say is that the ABI will not be changed because someone in the
> kernel decides they don't like it. So the options are: either fix it so
> it works, or accept that the code is broken and will never work on ARM.

I did never ask to change some ABI, sorry.
Still I can't see why this structure will cause alignment issues, as the
compiler will pad it up to the right boundary automagically, as you said
above. Why doesn't the ARM compiler do this?

--
Greetings Michael.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/