Commit de288e36 authored by Janusz Dziedzic's avatar Janusz Dziedzic Committed by Felipe Balbi

usb: dwc3: gadget: delay unmap of bounced requests

In the case of bounced ep0 requests, we must delay DMA operation until
after ->complete() otherwise we might overwrite contents of req->buf.

This caused problems with RNDIS gadget.
Signed-off-by: default avatarJanusz Dziedzic <januszx.dziedzic@intel.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent 97da3854
...@@ -171,6 +171,7 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, ...@@ -171,6 +171,7 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
int status) int status)
{ {
struct dwc3 *dwc = dep->dwc; struct dwc3 *dwc = dep->dwc;
unsigned int unmap_after_complete = false;
req->started = false; req->started = false;
list_del(&req->list); list_del(&req->list);
...@@ -180,11 +181,19 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, ...@@ -180,11 +181,19 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
if (req->request.status == -EINPROGRESS) if (req->request.status == -EINPROGRESS)
req->request.status = status; req->request.status = status;
if (dwc->ep0_bounced && dep->number <= 1) /*
* NOTICE we don't want to unmap before calling ->complete() if we're
* dealing with a bounced ep0 request. If we unmap it here, we would end
* up overwritting the contents of req->buf and this could confuse the
* gadget driver.
*/
if (dwc->ep0_bounced && dep->number <= 1) {
dwc->ep0_bounced = false; dwc->ep0_bounced = false;
unmap_after_complete = true;
usb_gadget_unmap_request_by_dev(dwc->sysdev, } else {
&req->request, req->direction); usb_gadget_unmap_request_by_dev(dwc->sysdev,
&req->request, req->direction);
}
trace_dwc3_gadget_giveback(req); trace_dwc3_gadget_giveback(req);
...@@ -192,6 +201,10 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, ...@@ -192,6 +201,10 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
usb_gadget_giveback_request(&dep->endpoint, &req->request); usb_gadget_giveback_request(&dep->endpoint, &req->request);
spin_lock(&dwc->lock); spin_lock(&dwc->lock);
if (unmap_after_complete)
usb_gadget_unmap_request_by_dev(dwc->sysdev,
&req->request, req->direction);
if (dep->number > 1) if (dep->number > 1)
pm_runtime_put(dwc->dev); pm_runtime_put(dwc->dev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment