[U-Boot] [PATCH] arm: enable unaligned access on ARMv7

Lucas Stach
2012-06-22T09:36:56Z

Am Freitag, den 22.06.2012, 11:15 +0200 schrieb Albert ARIBAUD:
> Hi Lucas,
>
> On Tue, 05 Jun 2012 21:06:20 +0200, Lucas Stach <dev@lynxeye.de> wrote:
> > Hi Stephen,
> >
> > Am Dienstag, den 05.06.2012, 12:42 -0600 schrieb Stephen Warren:
> > > On 06/05/2012 11:47 AM, Lucas Stach wrote:
> > > > Recent toolchains default to using the hardware feature for
> > > > unaligned access on ARM v7, rather than doing the software
> > > > fallback. According to ARM this is safe as all v7 implementations
> > > > have to support this feature.
> > > > (http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0471c/BABJFFAE.html)
> > > >
> > > > To avoid CPU hangs when doing unaligned memory access, we have to
> > > > turn off alignment checking in our CPU initialisation code.
> > > > (http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491c/CIHCGCFD.html)
> > >
> > > Does this behavior change trickle down to Linux/... too, or would
> > > an OS completely re-initialize this state, and hence not be
> > > affected?
> > >
> >
> > Linux in particular does reinitialize this state and I expect any
> > reasonable OS to do so.
>
> Then what is the point of enabling it on U-Boot? Does it fix some issue
> whereby some mis-aligned piece of data cannot be properly aligned?
>
Yes, it fixes U-Boot USB on Tegra, when built with a recent toolchain.
Fixing the alignment of some of the structures in the USB code should
also be done, but this is a whole lot more invasive and requires some
more thought, as the discussion about this on LKML shows. The issue
doesn't show for older toolchains, as they by default emit code to work
around unaligned accesses.

This patch fixes all unaligned issues, that may appear with recent
toolchains. We avoid having to instruct the toolchain to work around
unaligned accesses and gain better performance in cases where it is
needed.

Thanks,
Lucas