From ea7bbc32e1e0e6dc7abbf96338426e92d5fae7fa Mon Sep 17 00:00:00 2001 From: Anji jonnala Date: Mon, 26 Dec 2011 16:39:53 +0530 Subject: [PATCH] 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 --- drivers/usb/gadget/ci13xxx_udc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c index 6282389a214..703494abd72 100644 --- a/drivers/usb/gadget/ci13xxx_udc.c +++ b/drivers/usb/gadget/ci13xxx_udc.c @@ -1844,6 +1844,14 @@ __acquires(mEp->lock) } 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) &&