usb: ci13xxx_udc: unmap req DMA buffers upon cable disconnection
Device controller driver transfers the ownership of usb request buffer
memory to device DMA by making call to dma_map_single. CPU regains the
access only after making call to dma_unmap_single.
Upon request completion USB driver is performing dma_unmap_single and
accessing the memory.
Perform dma_unmap_single upon cable disconnect also while flushing the USB
requests.
Change-Id: Ic180c2b1158c93c5b187607c364f0fd5056cc52f
CRs-fixed: 327466
Signed-off-by: Anji jonnala <anjir@codeaurora.org>
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c
index 6282389..703494a 100644
--- a/drivers/usb/gadget/ci13xxx_udc.c
+++ b/drivers/usb/gadget/ci13xxx_udc.c
@@ -1844,6 +1844,14 @@
}
mReq->req.status = -ESHUTDOWN;
+ if (mReq->map) {
+ dma_unmap_single(mEp->device, mReq->req.dma,
+ mReq->req.length,
+ mEp->dir ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
+ mReq->req.dma = 0;
+ mReq->map = 0;
+ }
+
if (mReq->req.complete != NULL) {
spin_unlock(mEp->lock);
if ((mEp->type == USB_ENDPOINT_XFER_CONTROL) &&