Skip to content

Commit a1383b3

Browse files
Wesley Chenggregkh
authored andcommitted
usb: dwc3: gadget: Restart DWC3 gadget when enabling pullup
usb_gadget_deactivate/usb_gadget_activate does not execute the UDC start operation, which may leave EP0 disabled and event IRQs disabled when re-activating the function. Move the enabling/disabling of USB EP0 and device event IRQs to be performed in the pullup routine. Fixes: ae7e861 ("usb: dwc3: Stop active transfers before halting the controller") Tested-by: Michael Tretter <m.tretter@pengutronix.de> Cc: stable <stable@vger.kernel.org> Reported-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Wesley Cheng <wcheng@codeaurora.org> Link: https://lore.kernel.org/r/1609282837-21666-1-git-send-email-wcheng@codeaurora.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 718bf42 commit a1383b3

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

drivers/usb/dwc3/gadget.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,6 +2083,7 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend)
20832083

20842084
static void dwc3_gadget_disable_irq(struct dwc3 *dwc);
20852085
static void __dwc3_gadget_stop(struct dwc3 *dwc);
2086+
static int __dwc3_gadget_start(struct dwc3 *dwc);
20862087

20872088
static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
20882089
{
@@ -2145,6 +2146,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
21452146
dwc->ev_buf->lpos = (dwc->ev_buf->lpos + count) %
21462147
dwc->ev_buf->length;
21472148
}
2149+
} else {
2150+
__dwc3_gadget_start(dwc);
21482151
}
21492152

21502153
ret = dwc3_gadget_run_stop(dwc, is_on, false);
@@ -2319,10 +2322,6 @@ static int dwc3_gadget_start(struct usb_gadget *g,
23192322
}
23202323

23212324
dwc->gadget_driver = driver;
2322-
2323-
if (pm_runtime_active(dwc->dev))
2324-
__dwc3_gadget_start(dwc);
2325-
23262325
spin_unlock_irqrestore(&dwc->lock, flags);
23272326

23282327
return 0;
@@ -2348,13 +2347,6 @@ static int dwc3_gadget_stop(struct usb_gadget *g)
23482347
unsigned long flags;
23492348

23502349
spin_lock_irqsave(&dwc->lock, flags);
2351-
2352-
if (pm_runtime_suspended(dwc->dev))
2353-
goto out;
2354-
2355-
__dwc3_gadget_stop(dwc);
2356-
2357-
out:
23582350
dwc->gadget_driver = NULL;
23592351
spin_unlock_irqrestore(&dwc->lock, flags);
23602352

0 commit comments

Comments
 (0)