patch "usb: dwc3: gadget: Return proper request status" added to usb-linus
Subsystems (3)
This is a note to let you know that I've just added the patch titled
usb: dwc3: gadget: Return proper request status
to my usb git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
in the usb-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
From c7428dbddcf4ea1919e1c8e15f715b94ca359268 Mon Sep 17 00:00:00 2001
From: Thinh Nguyen <[email protected]>
Date: Fri, 22 Apr 2022 17:36:28 -0700
Subject: 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.
--- drivers/usb/dwc3/gadget.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)
drivers/usb/dwc3/gadget.c +30 -1
@@ -3274,6 +3274,7 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,const struct dwc3_event_depevt *event, struct dwc3_request *req, int status) { + int request_status;int ret;if (req->request.num_mapped_sgs)
@@ -3294,7 +3295,35 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep, req->needs_extra_trb = false; } -dwc3_gadget_giveback (dep, req, status); +/* +* The event status only reflects the status of the TRB with IOC set. +* For the requests that don't set interrupt on completion, the driver +* needs to check and return the status of the completed TRBs associated +* with the request. Use the status of the last TRB of the request. +*/ +if (req->request.no_interrupt) { +struct dwc3_trb *trb; + + trb =dwc3_ep_prev_trb (dep, dep->trb_dequeue); +switch (DWC3_TRB_SIZE_TRBSTS (trb->size)) { +case DWC3_TRBSTS_MISSED_ISOC : +/* Isoc endpoint only */ + request_status = -EXDEV ; +break ; +case DWC3_TRB_STS_XFER_IN_PROG : +/* Applicable when End Transfer with ForceRM=0 */ +case DWC3_TRBSTS_SETUP_PENDING : +/* Control endpoint only */ +case DWC3_TRBSTS_OK : +default : + request_status =0 ; +break ; + } + }else { + request_status = status; + } + +dwc3_gadget_giveback (dep, req, request_status); out:return ret;
Signature · 1 line
2.36.0