public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Alexander Stein <alexanders83@web.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 6/7] dwc2: Add dcache support
Date: Wed, 22 Jul 2015 20:23:37 +0200	[thread overview]
Message-ID: <1437589418-11978-7-git-send-email-alexanders83@web.de> (raw)
In-Reply-To: <1437589418-11978-1-git-send-email-alexanders83@web.de>

This adds dcache support for dwc2. The DMA buffers must be DMA aligned and
is flushed for outgoing transactions before starting transfer. For
ingoing transactions it is invalidated after the transfer has finished.

Signed-off-by: Alexander Stein <alexanders83@web.de>
---
 drivers/usb/host/dwc2.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index eee60a2..03fba8f 100644
--- a/drivers/usb/host/dwc2.c
+++ b/drivers/usb/host/dwc2.c
@@ -22,8 +22,8 @@
 #define DWC2_DATA_BUF_SIZE		(64 * 1024)
 
 /* We need doubleword-aligned buffers for DMA transfers */
-DEFINE_ALIGN_BUFFER(uint8_t, aligned_buffer, DWC2_DATA_BUF_SIZE, 8);
-DEFINE_ALIGN_BUFFER(uint8_t, status_buffer, DWC2_STATUS_BUF_SIZE, 8);
+DEFINE_ALIGN_BUFFER(uint8_t, aligned_buffer, DWC2_DATA_BUF_SIZE, ARCH_DMA_MINALIGN);
+DEFINE_ALIGN_BUFFER(uint8_t, status_buffer, DWC2_STATUS_BUF_SIZE, ARCH_DMA_MINALIGN);
 
 #define MAX_DEVICE			16
 #define MAX_ENDPOINT			16
@@ -802,9 +802,14 @@ int chunk_msg(struct usb_device *dev, unsigned long pipe, int *pid, int in,
 		       (*pid << DWC2_HCTSIZ_PID_OFFSET),
 		       &hc_regs->hctsiz);
 
-		if (!in)
+		if (!in) {
 			memcpy(aligned_buffer, (char *)buffer + done, len);
 
+			flush_dcache_range((unsigned long)aligned_buffer,
+				(unsigned long)((void *)aligned_buffer +
+				roundup(len, ARCH_DMA_MINALIGN)));
+		}
+
 		writel(phys_to_bus((unsigned long)aligned_buffer),
 		       &hc_regs->hcdma);
 
@@ -820,6 +825,11 @@ int chunk_msg(struct usb_device *dev, unsigned long pipe, int *pid, int in,
 
 		if (in) {
 			xfer_len -= sub;
+
+			invalidate_dcache_range((unsigned long)aligned_buffer,
+				(unsigned long)((void *)aligned_buffer +
+				roundup(xfer_len, ARCH_DMA_MINALIGN)));
+
 			memcpy(buffer + done, aligned_buffer, xfer_len);
 			if (sub)
 				stop_transfer = 1;
-- 
2.4.6

  parent reply	other threads:[~2015-07-22 18:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-22 18:23 [U-Boot] [PATCH v3 0/7] dcache support for Raspberry Pi 1 Alexander Stein
2015-07-22 18:23 ` [U-Boot] [PATCH v3 1/7] arm1136: Remove dead code Alexander Stein
2015-07-22 18:23 ` [U-Boot] [PATCH v3 2/7] arm1136/arm1176: Merge cache handling code Alexander Stein
2015-07-24  4:52   ` Stephen Warren
2015-07-22 18:23 ` [U-Boot] [PATCH v3 3/7] ARM: bcm283x: Define CONFIG_SYS_CACHELINE_SIZE Alexander Stein
2015-07-24  4:54   ` Stephen Warren
2015-07-22 18:23 ` [U-Boot] [PATCH v3 4/7] ARM: bcm283x: Allocate all mailbox buffers cacheline aligned Alexander Stein
2015-07-22 18:23 ` [U-Boot] [PATCH v3 5/7] arm/mach-bcm283x/mbox: Flush and invalidate dcache when using fw mailbox Alexander Stein
2015-07-22 18:23 ` Alexander Stein [this message]
2015-07-24  4:59   ` [U-Boot] [PATCH v3 6/7] dwc2: Add dcache support Stephen Warren
2015-07-22 18:23 ` [U-Boot] [PATCH v3 7/7] arm/rpi: Enable dcache Alexander Stein
2015-07-24  5:00   ` Stephen Warren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1437589418-11978-7-git-send-email-alexanders83@web.de \
    --to=alexanders83@web.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox