]> git.karo-electronics.de Git - karo-tx-uboot.git/commitdiff
usb: dwc2 : invalidate dcache before starting DMA
authorXu Ziyuan <xzy.xu@rock-chips.com>
Thu, 14 Jul 2016 06:52:35 +0000 (14:52 +0800)
committerSimon Glass <sjg@chromium.org>
Tue, 26 Jul 2016 02:44:19 +0000 (20:44 -0600)
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>
drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c

index 12f5c85c310e09cd3750f1bdd26f63c84270c66d..0d6d2fba8a0f3f22c8f69be5531a4f9282814be9 100644 (file)
@@ -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);