summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorXu Ziyuan <xzy.xu@rock-chips.com>2016-07-14 14:52:35 +0800
committerSimon Glass <sjg@chromium.org>2016-07-25 20:44:19 -0600
commit9424f1418377bfb0c95ed36a8854e7fe53436229 (patch)
tree33768026a1ec458f79ba7b19234b71d27bbd7497 /drivers/usb
parent47117882671fbfb5ffa20cd25ec29da5b7143009 (diff)
downloadu-boot-imx-9424f1418377bfb0c95ed36a8854e7fe53436229.zip
u-boot-imx-9424f1418377bfb0c95ed36a8854e7fe53436229.tar.gz
u-boot-imx-9424f1418377bfb0c95ed36a8854e7fe53436229.tar.bz2
usb: dwc2 : invalidate dcache before starting DMA
Invalidate dcache before starting the DMA to ensure coherency. In case there are any dirty lines from the DMA buffer in the cache, subsequent cache-line replacements may corrupt the buffer in memory while the DMA is still going on. Cache-line replacement can happen if the CPU tries to bring some other memory locations into the cache while the DMA is going on. Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
index 12f5c85..0d6d2fb 100644
--- a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
+++ b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
@@ -110,6 +110,9 @@ static int setdma_rx(struct dwc2_ep *ep, struct dwc2_request *req)
ctrl = readl(&reg->out_endp[ep_num].doepctl);
+ invalidate_dcache_range((unsigned long) ep->dma_buf,
+ (unsigned long) ep->dma_buf + ep->len);
+
writel((unsigned int) ep->dma_buf, &reg->out_endp[ep_num].doepdma);
writel(DOEPT_SIZ_PKT_CNT(pktcnt) | DOEPT_SIZ_XFER_SIZE(length),
&reg->out_endp[ep_num].doeptsiz);