Skip to content

Commit 49e0590

Browse files
Thinh Nguyenfelipebalbi
authored andcommitted
usb: dwc3: gadget: Fix request completion check
A request may not be completed because not all the TRBs are prepared for it. This happens when we run out of available TRBs. When some TRBs are completed, the driver needs to prepare the rest of the TRBs for the request. The check dwc3_gadget_ep_request_completed() shouldn't be checking the amount of data received but rather the number of pending TRBs. Revise this request completion check. Cc: [email protected] Fixes: e0c42ce ("usb: dwc3: gadget: simplify IOC handling") Signed-off-by: Thinh Nguyen <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
1 parent d0550cd commit 49e0590

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

drivers/usb/dwc3/gadget.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,14 +2510,7 @@ static int dwc3_gadget_ep_reclaim_trb_linear(struct dwc3_ep *dep,
25102510

25112511
static bool dwc3_gadget_ep_request_completed(struct dwc3_request *req)
25122512
{
2513-
/*
2514-
* For OUT direction, host may send less than the setup
2515-
* length. Return true for all OUT requests.
2516-
*/
2517-
if (!req->direction)
2518-
return true;
2519-
2520-
return req->request.actual == req->request.length;
2513+
return req->num_pending_sgs == 0;
25212514
}
25222515

25232516
static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
@@ -2541,8 +2534,7 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
25412534

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

2544-
if (!dwc3_gadget_ep_request_completed(req) ||
2545-
req->num_pending_sgs) {
2537+
if (!dwc3_gadget_ep_request_completed(req)) {
25462538
__dwc3_gadget_kick_transfer(dep);
25472539
goto out;
25482540
}

0 commit comments

Comments
 (0)