usb: dwc3: gadget: properly skip over trbs on ep_dequeue

The commit a7027ca69d ("usb: dwc3: gadget: Give back
staled requests") move all started request to cancelled
list and expect to give back all the started requests.
However, it fails to give back the started requests
if the dep->flags isn't set to DWC3_EP_TRANSFER_STARTED,
in this case, we need to skip the trbs and giveback the
req. And we also need to skip the trbs of the req in the
pending_list to make the dequeue pointers useless.

Signed-off-by: William Wu <william.wu@rock-chips.com>
Change-Id: I123ff779d5e2933449581f8b570e2e6ad6b75458
This commit is contained in:
William Wu
2022-04-26 20:32:21 +08:00
committed by Tao Huang
parent f673a58a7b
commit 2007d5815e

View File

@@ -2018,6 +2018,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
list_for_each_entry(r, &dep->pending_list, list) {
if (r == req) {
dwc3_gadget_ep_skip_trbs(dep, req);
dwc3_gadget_giveback(dep, req, -ECONNRESET);
goto out;
}
@@ -2025,8 +2026,6 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
list_for_each_entry(r, &dep->started_list, list) {
if (r == req) {
struct dwc3_request *t;
/* wait until it is processed */
dwc3_stop_active_transfer(dep, true, true);
@@ -2034,12 +2033,15 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
* Remove any started request if the transfer is
* cancelled.
*/
list_for_each_entry_safe(r, t, &dep->started_list, list)
dwc3_gadget_move_cancelled_request(r,
DWC3_REQUEST_STATUS_DEQUEUED);
dwc3_gadget_move_cancelled_request(r, DWC3_REQUEST_STATUS_DEQUEUED);
dep->flags &= ~DWC3_EP_WAIT_TRANSFER_COMPLETE;
if (!(dep->flags & DWC3_EP_TRANSFER_STARTED)) {
dwc3_gadget_ep_skip_trbs(dep, req);
dwc3_gadget_giveback(dep, req, -ECONNRESET);
}
goto out;
}
}