Skip to content

Commit 4a1e25c

Browse files
Wesley Chenggregkh
authored andcommitted
usb: dwc3: gadget: Stop EP0 transfers during pullup disable
During a USB cable disconnect, or soft disconnect scenario, a pending SETUP transaction may not be completed, leading to the following error: dwc3 a600000.dwc3: timed out waiting for SETUP phase If this occurs, then the entire pullup disable routine is skipped and proper cleanup and halting of the controller does not complete. Instead of returning an error (which is ignored from the UDC perspective), allow the pullup disable routine to continue, which will also handle disabling of EP0/1. This will end any active transfers as well. Ensure to clear any delayed_status also, as the timeout could happen within the STATUS stage. Fixes: bb01473 ("usb: dwc3: gadget: don't clear RUN/STOP when it's invalid to do so") Cc: <[email protected]> Reviewed-by: Thinh Nguyen <[email protected]> Acked-by: Felipe Balbi <[email protected]> Signed-off-by: Wesley Cheng <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 51f1954 commit 4a1e25c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/usb/dwc3/gadget.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,10 +2243,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
22432243

22442244
ret = wait_for_completion_timeout(&dwc->ep0_in_setup,
22452245
msecs_to_jiffies(DWC3_PULL_UP_TIMEOUT));
2246-
if (ret == 0) {
2247-
dev_err(dwc->dev, "timed out waiting for SETUP phase\n");
2248-
return -ETIMEDOUT;
2249-
}
2246+
if (ret == 0)
2247+
dev_warn(dwc->dev, "timed out waiting for SETUP phase\n");
22502248
}
22512249

22522250
/*
@@ -2458,6 +2456,7 @@ static int __dwc3_gadget_start(struct dwc3 *dwc)
24582456
/* begin to receive SETUP packets */
24592457
dwc->ep0state = EP0_SETUP_PHASE;
24602458
dwc->link_state = DWC3_LINK_STATE_SS_DIS;
2459+
dwc->delayed_status = false;
24612460
dwc3_ep0_out_start(dwc);
24622461

24632462
dwc3_gadget_enable_irq(dwc);

0 commit comments

Comments
 (0)