Skip to content

Commit c4e3ef5

Browse files
Thinh Nguyengregkh
authored andcommitted
usb: dwc3: gadget: Ignore End Transfer delay on teardown
If we delay sending End Transfer for Setup TRB to be prepared, we need to check if the End Transfer was in preparation for a driver teardown/soft-disconnect. In those cases, just send the End Transfer command without delay. In the case of soft-disconnect, there's a very small chance the command may not go through immediately. But should it happen, the Setup TRB will be prepared during the polling of the controller halted state, allowing the command to go through then. In the case of disabling endpoint due to reconfiguration (e.g. set_interface(alt-setting) or usb reset), then it's driven by the host. Typically the host wouldn't immediately cancel the control request and send another control transfer to trigger the End Transfer command timeout. Fixes: 4db0fbb ("usb: dwc3: gadget: Don't delay End Transfer on delayed_status") Cc: [email protected] Signed-off-by: Thinh Nguyen <[email protected]> Link: https://lore.kernel.org/r/f1617a323e190b9cc408fb8b65456e32b5814113.1670546756.git.Thinh.Nguyen@synopsys.com Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e498a04 commit c4e3ef5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/usb/dwc3/gadget.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1727,6 +1727,7 @@ static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool int
17271727
else if (!ret)
17281728
dep->flags |= DWC3_EP_END_TRANSFER_PENDING;
17291729

1730+
dep->flags &= ~DWC3_EP_DELAY_STOP;
17301731
return ret;
17311732
}
17321733

@@ -3732,8 +3733,10 @@ void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force,
37323733
if (dep->number <= 1 && dwc->ep0state != EP0_DATA_PHASE)
37333734
return;
37343735

3736+
if (interrupt && (dep->flags & DWC3_EP_DELAY_STOP))
3737+
return;
3738+
37353739
if (!(dep->flags & DWC3_EP_TRANSFER_STARTED) ||
3736-
(dep->flags & DWC3_EP_DELAY_STOP) ||
37373740
(dep->flags & DWC3_EP_END_TRANSFER_PENDING))
37383741
return;
37393742

0 commit comments

Comments
 (0)