From 43084a4a6ddefab3ac985a664680704598bf757e Mon Sep 17 00:00:00 2001 From: Firefly Date: Mon, 17 Aug 2015 16:17:23 +0800 Subject: [PATCH] [u-boot] usb: dwc_hcd: fix cache consistency issue --- u-boot/drivers/usb/host/dwc_hcd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/u-boot/drivers/usb/host/dwc_hcd.c b/u-boot/drivers/usb/host/dwc_hcd.c index e62c8ae02c..614ce81c37 100755 --- a/u-boot/drivers/usb/host/dwc_hcd.c +++ b/u-boot/drivers/usb/host/dwc_hcd.c @@ -482,6 +482,10 @@ dwc2_transfer(struct usb_device *dev, unsigned long pipe, int size, if (do_copy && (dir == EPDIR_OUT)) memcpy(aligned_buf, data_buf, size); + if (dir == EPDIR_OUT) + flush_dcache_range(aligned_buf, aligned_buf + + roundup(size, ARCH_DMA_MINALIGN)); + writel(hctsiz.d32, ®->Host.hchn[ch_num].hctsizn); writel((uint32_t)aligned_buf, ®->Host.hchn[ch_num].hcdman); writel(hcchar.d32, ®->Host.hchn[ch_num].hccharn); @@ -492,6 +496,10 @@ dwc2_transfer(struct usb_device *dev, unsigned long pipe, int size, /* Calculate actual transferred length */ transferred = (dir == EPDIR_IN) ? inpkt_length - ret : ret; + if (dir == EPDIR_IN) + invalidate_dcache_range(aligned_buf, aligned_buf + + roundup(transferred, ARCH_DMA_MINALIGN)); + if (do_copy && (dir == EPDIR_IN)) memcpy(data_buf, aligned_buf, transferred); } @@ -505,6 +513,7 @@ dwc2_transfer(struct usb_device *dev, unsigned long pipe, int size, printf("%s Transfer stop code: %d\n", __func__, ret); return ret; } + return transferred; }