linux/drivers/usb/chipidea
Michael Grzeschik a9c174302b usb: chipidea: udc: fix memory access of shared memory on armv5 machines
The udc uses an shared dma memory space between hard and software. This
memory layout is described in ci13xxx_qh and ci13xxx_td which are marked
with the attribute ((packed)).

The compiler currently does not know about the alignment of the memory
layout, and will create strb and ldrb operations.

The Datasheet of the synopsys core describes, that some operations on
the mapped memory need to be atomic double word operations. I.e. the
next pointer addressing in the qhead, as otherwise the hardware will
read wrong data and totally stuck.

This is also possible while working with the current active td queue,
and preparing the td->ptr.next in software while the hardware is still
working with the current active td which is supposed to be changed:

writeb(0xde, &td->ptr.next + 0x0); /* strb */
writeb(0xad, &td->ptr.next + 0x1); /* strb */

<----- hardware reads value of td->ptr.next and get stuck!

writeb(0xbe, &td->ptr.next + 0x2); /* strb */
writeb(0xef, &td->ptr.next + 0x3); /* strb */

This appeares on armv5 machines where the hardware does not support
unaligned 32bit operations.

This patch adds the attribute ((aligned(4))) to the structures to tell
the compiler to use 32bit operations. It also adds an wmb() for the
prepared TD data before it gets enqueued into the qhead.

Cc: stable <stable@vger.kernel.org> # v3.5
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Reviewed-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-05 13:43:14 -07:00
..
bits.h usb: chipidea: add host role 2012-05-11 16:56:15 -07:00
ci.h usb: chipidea: udc: add the define TD_PAGE_COUNT and fix all users 2013-03-30 08:20:49 -07:00
ci13xxx_imx.c usb: chipidea: usbmisc: add post handling and errata fix for mx25 2013-03-30 08:13:58 -07:00
ci13xxx_imx.h usb: chipidea: usbmisc: add post handling and errata fix for mx25 2013-03-30 08:13:58 -07:00
ci13xxx_msm.c usb: remove use of __devexit 2012-11-21 13:27:17 -08:00
ci13xxx_pci.c usb: chipidea: make pci platform datas static 2013-03-30 08:13:58 -07:00
core.c usb: chipidea: big-endian support 2013-03-30 08:20:47 -07:00
debug.c usb: chipidea: fix precedence bug in ci_requests_show() 2013-03-30 08:08:40 -07:00
debug.h usb: chipidea: convert debug entries in sysfs to debugfs 2013-03-30 08:08:39 -07:00
host.c usb: chipidea: Allow disabling streaming not only in udc mode 2013-01-11 16:01:07 -08:00
host.h usb: chipidea: add host role 2012-05-11 16:56:15 -07:00
Kconfig USB: EHCI: fix build error by making ChipIdea host a normal EHCI driver 2012-11-02 10:03:50 -07:00
Makefile usb: chipidea: usbmisc: rename file, struct and functions to usbmisc_imx 2013-03-30 08:13:57 -07:00
udc.c usb: chipidea: udc: fix memory access of shared memory on armv5 machines 2013-04-05 13:43:14 -07:00
udc.h usb: chipidea: udc: fix memory access of shared memory on armv5 machines 2013-04-05 13:43:14 -07:00
usbmisc_imx.c usb: chipidea: usbmisc: add post handling and errata fix for mx25 2013-03-30 08:13:58 -07:00