From 28fabd5ee2b10fb07e2dae96492af2afe25ff466 Mon Sep 17 00:00:00 2001 From: Jack Pham Date: Sat, 28 Jun 2014 00:36:38 -0700 Subject: [PATCH] usb: dwc3: Ensure req->dma is initialized to DMA_ERROR_CODE commit 269a1b78 "usb: gadget: Add support for DMA mapping optimization of request buffers" added checks to usb_gadget_{map,unmap}_request() to support the pre-mapped DMA buffers that a function can map ahead of time before enqueing the request. However, these routines check the req->dma for a sentinel value, DMA_ERROR_CODE, in order to determine whether or not to proceed with dma_map/unmap(). This means that UDC drivers should initialize to this value when allocating each new request. Do this in the dwc3 gadget driver in order to properly support this. This fixes an issue in which usb_gadget_unmap_request() was incorrectly being called on an uninitialized (as 0) req->dma address, and proceeds to call dma_unmap() which interprets it as physical address 0x0. Change-Id: I514d2b824e272c6c42c483febaa1c4084b0d09ee Signed-off-by: Jack Pham --- drivers/usb/dwc3/gadget.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index a4ca2f62b740..377281662cd0 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -774,6 +774,7 @@ static struct usb_request *dwc3_gadget_ep_alloc_request(struct usb_ep *ep, req->epnum = dep->number; req->dep = dep; + req->request.dma = DMA_ERROR_CODE; trace_dwc3_alloc_request(req);