Skip to content

Commit

Permalink
usb: dwc3: gadget: move requests to cancelled_list
Browse files Browse the repository at this point in the history
Whenever we have a request in flight, we can move it to the cancelled
list and later simply iterate over that list and skip over any TRBs we
find.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
  • Loading branch information
Felipe Balbi committed Nov 26, 2018
1 parent d5443bb commit d4f1afe
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions drivers/usb/dwc3/gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,17 @@ static void dwc3_gadget_ep_skip_trbs(struct dwc3_ep *dep, struct dwc3_request *r
}
}

static void dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep)
{
struct dwc3_request *req;
struct dwc3_request *tmp;

list_for_each_entry_safe(req, tmp, &dep->cancelled_list, list) {
dwc3_gadget_ep_skip_trbs(dep, req);
dwc3_gadget_giveback(dep, req, -ECONNRESET);
}
}

static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
struct usb_request *request)
{
Expand Down Expand Up @@ -1534,16 +1545,16 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
if (!r->trb)
goto out0;

dwc3_gadget_ep_skip_trbs(dep, r);
goto out1;
dwc3_gadget_move_cancelled_request(req);
dwc3_gadget_ep_cleanup_cancelled_requests(dep);
goto out0;
}
dev_err(dwc->dev, "request %pK was not queued to %s\n",
request, ep->name);
ret = -EINVAL;
goto out0;
}

out1:
dwc3_gadget_giveback(dep, req, -ECONNRESET);

out0:
Expand Down

0 comments on commit d4f1afe

Please sign in to comment.