Skip to content

Commit

Permalink
usb: dwc3: gadget: Reclaim extra TRBs after request completion
Browse files Browse the repository at this point in the history
[ Upstream commit 690e5c2dc29f8891fcfd30da67e0d5837c2c9df5 ]

An SG request may be partially completed (due to no available TRBs).
Don't reclaim extra TRBs and clear the needs_extra_trb flag until the
request is fully completed. Otherwise, the driver will reclaim the wrong
TRB.

Cc: stable@vger.kernel.org
Fixes: 1f51211 ("usb: dwc3: gadget: add remaining sg entries to ring")
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Thinh Nguyen authored and wh0dat committed Jan 22, 2021
1 parent 192d1ce commit e919d13
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/usb/dwc3/gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -3313,6 +3313,11 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event,
status);

req->request.actual = req->request.length - req->remaining;

if (!dwc3_gadget_ep_request_completed(req))
goto out;

if (req->needs_extra_trb) {
unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);

Expand All @@ -3328,11 +3333,6 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
req->needs_extra_trb = false;
}

req->request.actual = req->request.length - req->remaining;

if (!dwc3_gadget_ep_request_completed(req))
goto out;

dwc3_gadget_giveback(dep, req, status);

out:
Expand Down

0 comments on commit e919d13

Please sign in to comment.