[PATCH] usb: fix unaligned access

Sascha Hauer s.hauer at pengutronix.de
Mon Oct 24 15:30:42 EDT 2011


On Mon, Oct 24, 2011 at 09:02:53PM +0200, Eric Bénard wrote:
> Hi,
> 
> Le 24/10/2011 20:37, Fabian van der Werf a écrit :
> >
> >Okay, I think it may be a compiler problem. The latest code sourcery
> >compiler builds a barebox that breaks on usb. 2009q1-203 builds fine,
> >however.
> >
> >In the usb code the compiler should be able to figure out that the
> >access is unaligned from the packed structure. So I guess it should
> >split up the access in multiple loads/stores. I will look into the
> >binaries to confirm this. The latest compiler may be broken or maybe
> >the default behaviour has changed because armv7 actually supports
> >unaligned access.
> >
> can't this be the same problem described here with gcc 4.6 :
> https://bugs.launchpad.net/ubuntu/+source/linux/+bug/791552
> 
> solved by this patch :
> https://launchpadlibrarian.net/73908303/0001-USB-ehci-remove-structure-packing-from-ehci_def.patch
> 
> with the following explanation :
> The kernel source marks ehci_regs as packed. gcc 4.6 treats all
> accesses to packed structures as unaligned and ends up reading the
> status register multiple times.

If Fabians compiler would treat every access to packed structure members
as unaligned everything would be fine. The problem seems to be that it
doesn't treat it as unaligned. Let's wait for Fabians binary analysis.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list