@@ -34,7 +34,7 @@ struct ehci_hccr *hccr; /* R/O registers, not need for volatile */
volatile struct ehci_hcor *hcor;
static uint16_t portreset;
-static struct QH qh_list __attribute__((aligned(32)));
+static struct QH qh_list __attribute__((aligned(USB_DMA_MINALIGN)));
static struct descriptor {
struct usb_hub_descriptor hub;
@@ -207,8 +207,8 @@ static int
ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
int length, struct devrequest *req)
{
- static struct QH qh __attribute__((aligned(32)));
- static struct qTD qtd[3] __attribute__((aligned (32)));
+ static struct QH qh __attribute__((aligned(USB_DMA_MINALIGN)));
+ static struct qTD qtd[3] __attribute__((aligned(USB_DMA_MINALIGN)));
int qtd_counter = 0;
volatile struct qTD *vtd;
@@ -145,7 +145,7 @@ struct musb_regs {
struct musb_epN_regs epN;
} ep[16];
-} __attribute__((packed, aligned(32)));
+} __attribute__((packed, aligned(USB_DMA_MINALIGN)));
#endif
/*
@@ -29,6 +29,16 @@
#include <usb_defs.h>
#include <usbdescriptors.h>
+/*
+ * The EHCI spec says that we must align to at least 32 bytes. However,
+ * some platforms require larger alignment.
+ */
+#if ARCH_DMA_MINALIGN > 32
+#define USB_DMA_MINALIGN ARCH_DMA_MINALIGN
+#else
+#define USB_DMA_MINALIGN 32
+#endif
+
/* Everything is aribtrary */
#define USB_ALTSETTINGALLOC 4
#define USB_MAXALTSETTING 128 /* Hard limit */
The USB spec says that 32 bytes is the minimum required alignment. However on some platforms we have a larger minimum requirement for cache coherency. In those cases, use that value rather than the USB spec minimum. We add a cpp check to <usb.h> to define USB_DMA_MINALIGN and make use of it in ehci-hcd.c and musb_core.h. We cannot use MAX() here as we are not allowed to have tests inside of align(...). Cc: Marek Vasut <marex@denx.de> Signed-off-by: Tom Rini <trini@ti.com> -- Changes in v4: - Re-checking shows we do not need to add alignment to rootdev/hcor/hccr Changes in v2: - Move test to <usb.h>, expand comment. --- drivers/usb/host/ehci-hcd.c | 6 +++--- drivers/usb/musb/musb_core.h | 2 +- include/usb.h | 10 ++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-)