Skip to content

Commit c7428db

Browse files
Thinh Nguyengregkh
authored andcommitted
usb: dwc3: gadget: Return proper request status
If the user sets the usb_request's no_interrupt, then there will be no completion event for the request. Currently the driver incorrectly uses the event status of a different request to report the status for a request with no_interrupt. The dwc3 driver needs to check the TRB status associated with the request when reporting its status. Note: this is only applicable to missed_isoc TRB completion status, but the other status are also listed for completeness/documentation. Fixes: 6d8a019 ("usb: dwc3: gadget: check for Missed Isoc from event status") Cc: <[email protected]> Signed-off-by: Thinh Nguyen <[email protected]> Link: https://lore.kernel.org/r/db2c80108286cfd108adb05bad52138b78d7c3a7.1650673655.git.Thinh.Nguyen@synopsys.com Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 973e0f7 commit c7428db

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

drivers/usb/dwc3/gadget.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3274,6 +3274,7 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
32743274
const struct dwc3_event_depevt *event,
32753275
struct dwc3_request *req, int status)
32763276
{
3277+
int request_status;
32773278
int ret;
32783279

32793280
if (req->request.num_mapped_sgs)
@@ -3294,7 +3295,35 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
32943295
req->needs_extra_trb = false;
32953296
}
32963297

3297-
dwc3_gadget_giveback(dep, req, status);
3298+
/*
3299+
* The event status only reflects the status of the TRB with IOC set.
3300+
* For the requests that don't set interrupt on completion, the driver
3301+
* needs to check and return the status of the completed TRBs associated
3302+
* with the request. Use the status of the last TRB of the request.
3303+
*/
3304+
if (req->request.no_interrupt) {
3305+
struct dwc3_trb *trb;
3306+
3307+
trb = dwc3_ep_prev_trb(dep, dep->trb_dequeue);
3308+
switch (DWC3_TRB_SIZE_TRBSTS(trb->size)) {
3309+
case DWC3_TRBSTS_MISSED_ISOC:
3310+
/* Isoc endpoint only */
3311+
request_status = -EXDEV;
3312+
break;
3313+
case DWC3_TRB_STS_XFER_IN_PROG:
3314+
/* Applicable when End Transfer with ForceRM=0 */
3315+
case DWC3_TRBSTS_SETUP_PENDING:
3316+
/* Control endpoint only */
3317+
case DWC3_TRBSTS_OK:
3318+
default:
3319+
request_status = 0;
3320+
break;
3321+
}
3322+
} else {
3323+
request_status = status;
3324+
}
3325+
3326+
dwc3_gadget_giveback(dep, req, request_status);
32983327

32993328
out:
33003329
return ret;

0 commit comments

Comments
 (0)