Commit a1383b35 authored by Wesley Cheng's avatar Wesley Cheng Committed by Greg Kroah-Hartman

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: ae7e8610 ("usb: dwc3: Stop active transfers before halting the controller")
Tested-by: default avatarMichael Tretter <m.tretter@pengutronix.de>
Cc: stable <stable@vger.kernel.org>
Reported-by: default avatarMichael Tretter <m.tretter@pengutronix.de>
Signed-off-by: default avatarWesley Cheng <wcheng@codeaurora.org>
Link: https://lore.kernel.org/r/1609282837-21666-1-git-send-email-wcheng@codeaurora.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 718bf42b
...@@ -2083,6 +2083,7 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend) ...@@ -2083,6 +2083,7 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend)
static void dwc3_gadget_disable_irq(struct dwc3 *dwc); static void dwc3_gadget_disable_irq(struct dwc3 *dwc);
static void __dwc3_gadget_stop(struct dwc3 *dwc); static void __dwc3_gadget_stop(struct dwc3 *dwc);
static int __dwc3_gadget_start(struct dwc3 *dwc);
static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
{ {
...@@ -2145,6 +2146,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) ...@@ -2145,6 +2146,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
dwc->ev_buf->lpos = (dwc->ev_buf->lpos + count) % dwc->ev_buf->lpos = (dwc->ev_buf->lpos + count) %
dwc->ev_buf->length; dwc->ev_buf->length;
} }
} else {
__dwc3_gadget_start(dwc);
} }
ret = dwc3_gadget_run_stop(dwc, is_on, false); ret = dwc3_gadget_run_stop(dwc, is_on, false);
...@@ -2319,10 +2322,6 @@ static int dwc3_gadget_start(struct usb_gadget *g, ...@@ -2319,10 +2322,6 @@ static int dwc3_gadget_start(struct usb_gadget *g,
} }
dwc->gadget_driver = driver; dwc->gadget_driver = driver;
if (pm_runtime_active(dwc->dev))
__dwc3_gadget_start(dwc);
spin_unlock_irqrestore(&dwc->lock, flags); spin_unlock_irqrestore(&dwc->lock, flags);
return 0; return 0;
...@@ -2348,13 +2347,6 @@ static int dwc3_gadget_stop(struct usb_gadget *g) ...@@ -2348,13 +2347,6 @@ static int dwc3_gadget_stop(struct usb_gadget *g)
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&dwc->lock, flags); spin_lock_irqsave(&dwc->lock, flags);
if (pm_runtime_suspended(dwc->dev))
goto out;
__dwc3_gadget_stop(dwc);
out:
dwc->gadget_driver = NULL; dwc->gadget_driver = NULL;
spin_unlock_irqrestore(&dwc->lock, flags); spin_unlock_irqrestore(&dwc->lock, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment