All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ziyuan Xu <xzy.xu@rock-chips.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 4/4] usb: dwc2 : invalidate dcache before starting DMA
Date: Thu, 14 Jul 2016 14:52:35 +0800	[thread overview]
Message-ID: <1468479155-1796-5-git-send-email-xzy.xu@rock-chips.com> (raw)
In-Reply-To: <1468479155-1796-1-git-send-email-xzy.xu@rock-chips.com>

From: Xu Ziyuan <xzy.xu@rock-chips.com>

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>

---

Changes in v4: None
Changes in v3:
- New commit since v3 to fix the coherence issue between memory and
cache

Changes in v2: None

 drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 3 +++
 1 file changed, 3 insertions(+)

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);
-- 
1.9.1

  parent reply	other threads:[~2016-07-14  6:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-14  6:52 [U-Boot] [PATCH v4 0/4] rockchip: rk3288: add fastboot support Ziyuan Xu
2016-07-14  6:52 ` [U-Boot] [PATCH v4 1/4] usb: rockchip-phy: implement USB2.0 phy control Ziyuan Xu
2016-07-15  3:20   ` Simon Glass
2016-07-15  3:56     ` Simon Glass
2016-07-14  6:52 ` [U-Boot] [PATCH v4 2/4] usb: dwc2-otg: adjust fifo size via platform data Ziyuan Xu
2016-07-15  3:20   ` Simon Glass
2016-07-15  3:56     ` Simon Glass
2016-07-16  5:43       ` Marek Vasut
2016-07-16 20:59         ` Simon Glass
2016-07-14  6:52 ` [U-Boot] [PATCH v4 3/4] rockchip: rk3288: add fastboot support Ziyuan Xu
2016-07-14 11:06   ` William.wu
2016-07-14 15:51     ` Ziyuan Xu
2016-07-14 16:26   ` [U-Boot] [PATCH v4.1 " Ziyuan Xu
2016-07-15  3:20     ` Simon Glass
2016-07-15 14:05       ` Ziyuan Xu
2016-07-15 14:38         ` Simon Glass
2016-07-16 22:31       ` Simon Glass
2016-07-14  6:52 ` Ziyuan Xu [this message]
2016-07-15  3:20   ` [U-Boot] [PATCH v4 4/4] usb: dwc2 : invalidate dcache before starting DMA Simon Glass
2016-07-15  3:56     ` Simon Glass

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=1468479155-1796-5-git-send-email-xzy.xu@rock-chips.com \
    --to=xzy.xu@rock-chips.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.