From patchwork Wed Jun 20 22:14:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rini X-Patchwork-Id: 166153 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 285DDB6FA4 for ; Thu, 21 Jun 2012 08:14:51 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 892AC280C5; Thu, 21 Jun 2012 00:14:47 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JCIqPRa6kYFX; Thu, 21 Jun 2012 00:14:47 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 42BB62808C; Thu, 21 Jun 2012 00:14:42 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4F68F28090 for ; Thu, 21 Jun 2012 00:14:36 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IHBOAGVA+G7Z for ; Thu, 21 Jun 2012 00:14:35 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pb0-f44.google.com (mail-pb0-f44.google.com [209.85.160.44]) by theia.denx.de (Postfix) with ESMTPS id 3F4252808D for ; Thu, 21 Jun 2012 00:14:34 +0200 (CEST) Received: by pbcwy7 with SMTP id wy7so1162401pbc.3 for ; Wed, 20 Jun 2012 15:14:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=wHuIKtvINvLYmI62wh11pYI3cCg/TExzUyU3lkgUIU0=; b=TtfuElkVL0575NGiDXwu3P4LUekkt8HZMXQ+SkTP7wplWrrwmqx0SXZmraOhLCNSnm C9DQy5KAyRcQUIvb/U5Jw6xZz9rfHA+g65v5T2bOmjutUGj4kzJPiBcDzYUqlCz2kCS8 NUJCRffdTEg2iYmqrNTFR4B8yuP5G4qOAXtMczSE7hmgp4CiclLIq35HnhflhXc5+++j ajjEVlvY2KeGitXCe8LdU/G3SgMWhfw8KwOi+kYfQNDPpTsvD7PieAzgBpFURgYVwNNZ DCsHQbJkO6cAMK7pP+eWOI8ydSe0rgm+x+INHh7wVgljlCrCaQ3pUUEJJdAXX6dlbVPr aYuw== Received: by 10.68.194.6 with SMTP id hs6mr82347614pbc.133.1340230473282; Wed, 20 Jun 2012 15:14:33 -0700 (PDT) Received: from bill-the-cat.ph.cox.net (ip68-230-54-74.ph.ph.cox.net. [68.230.54.74]) by mx.google.com with ESMTPS id pq5sm4774104pbb.30.2012.06.20.15.14.31 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 20 Jun 2012 15:14:32 -0700 (PDT) From: Tom Rini To: u-boot@lists.denx.de Date: Wed, 20 Jun 2012 15:14:24 -0700 Message-Id: <1340230468-12811-3-git-send-email-trini@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1340230468-12811-1-git-send-email-trini@ti.com> References: <1340209283-3404-1-git-send-email-trini@ti.com> <1340230468-12811-1-git-send-email-trini@ti.com> Cc: Marek Vasut Subject: [U-Boot] [PATCH v4 2/6] ehci-hcd.c, musb_core, usb.h: Add USB_DMA_MINALIGN define for cache alignment X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 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 Signed-off-by: Tom Rini --- Changes in v4: - Re-checking shows we do not need to add alignment to rootdev/hcor/hccr Changes in v2: - Move test to , 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(-) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 04300be..d34c675 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -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; diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index a8adcce..e914369 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -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 /* diff --git a/include/usb.h b/include/usb.h index 6da91e7..ba3d169 100644 --- a/include/usb.h +++ b/include/usb.h @@ -29,6 +29,16 @@ #include #include +/* + * 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 */