This is a note to let you know that I've just added the patch titled usb: dwc3: gadget: Ignore End Transfer delay on teardown to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: usb-dwc3-gadget-ignore-end-transfer-delay-on-teardown.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From c4e3ef5685393c5051b52cf1e94b8891d49793ab Mon Sep 17 00:00:00 2001 From: Thinh Nguyen <Thinh.Nguyen@xxxxxxxxxxxx> Date: Thu, 8 Dec 2022 16:50:35 -0800 Subject: usb: dwc3: gadget: Ignore End Transfer delay on teardown From: Thinh Nguyen <Thinh.Nguyen@xxxxxxxxxxxx> commit c4e3ef5685393c5051b52cf1e94b8891d49793ab upstream. 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: 4db0fbb60136 ("usb: dwc3: gadget: Don't delay End Transfer on delayed_status") Cc: stable@xxxxxxxxxxxxxxx Signed-off-by: Thinh Nguyen <Thinh.Nguyen@xxxxxxxxxxxx> Link: https://lore.kernel.org/r/f1617a323e190b9cc408fb8b65456e32b5814113.1670546756.git.Thinh.Nguyen@xxxxxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/usb/dwc3/gadget.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1701,6 +1701,7 @@ static int __dwc3_stop_active_transfer(s dep->flags |= DWC3_EP_END_TRANSFER_PENDING; } + dep->flags &= ~DWC3_EP_DELAY_STOP; return ret; } @@ -3710,8 +3711,10 @@ void dwc3_stop_active_transfer(struct dw if (dep->number <= 1 && dwc->ep0state != EP0_DATA_PHASE) return; + if (interrupt && (dep->flags & DWC3_EP_DELAY_STOP)) + return; + if (!(dep->flags & DWC3_EP_TRANSFER_STARTED) || - (dep->flags & DWC3_EP_DELAY_STOP) || (dep->flags & DWC3_EP_END_TRANSFER_PENDING)) return; Patches currently in stable-queue which might be from Thinh.Nguyen@xxxxxxxxxxxx are queue-5.15/usb-dwc3-gadget-fix-null-pointer-dereference-in-dwc3_gadget_suspend.patch queue-5.15/usb-dwc3-gadget-refactor-ep0-forced-stall-restart-in.patch queue-5.15/usb-dwc3-gadget-delay-issuing-end-transfer.patch queue-5.15/usb-dwc3-gadget-don-t-delay-end-transfer-on-delayed_status.patch queue-5.15/usb-dwc3-gadget-ignore-end-transfer-delay-on-teardown.patch queue-5.15/usb-dwc3-gadget-submit-endxfer-command-if-delayed-du.patch queue-5.15/usb-dwc3-gadget-execute-gadget-stop-after-halting-the-controller.patch queue-5.15/usb-dwc3-gadget-only-end-transfer-for-ep0-data-phase.patch queue-5.15/usb-dwc3-gadget-handle-ep0-request-dequeuing-properl.patch queue-5.15/usb-dwc3-host-set-xhci_sg_trb_cache_size_quirk.patch queue-5.15/usb-dwc3-gadget-stall-and-restart-ep0-if-host-is-unr.patch queue-5.15/usb-dwc3-gadget-force-sending-delayed-status-during-.patch queue-5.15/usb-dwc3-ep0-don-t-prepare-beyond-setup-stage.patch queue-5.15/usb-dwc3-gadget-wait-for-ep0-xfers-to-complete-durin.patch