Skip to content

Commit 77adb8b

Browse files
Wesley Chenggregkh
authored andcommitted
usb: dwc3: gadget: Allow runtime suspend if UDC unbinded
The DWC3 runtime suspend routine checks for the USB connected parameter to determine if the controller can enter into a low power state. The connected state is only set to false after receiving a disconnect event. However, in the case of a device initiated disconnect (i.e. UDC unbind), the controller is halted and a disconnect event is never generated. Set the connected flag to false if issuing a device initiated disconnect to allow the controller to be suspended. 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 8280de6 commit 77adb8b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/usb/dwc3/gadget.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,6 +2107,17 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
21072107
}
21082108
}
21092109

2110+
/*
2111+
* Check the return value for successful resume, or error. For a
2112+
* successful resume, the DWC3 runtime PM resume routine will handle
2113+
* the run stop sequence, so avoid duplicate operations here.
2114+
*/
2115+
ret = pm_runtime_get_sync(dwc->dev);
2116+
if (!ret || ret < 0) {
2117+
pm_runtime_put(dwc->dev);
2118+
return 0;
2119+
}
2120+
21102121
/*
21112122
* Synchronize any pending event handling before executing the controller
21122123
* halt routine.
@@ -2145,10 +2156,12 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
21452156
dwc->ev_buf->lpos = (dwc->ev_buf->lpos + count) %
21462157
dwc->ev_buf->length;
21472158
}
2159+
dwc->connected = false;
21482160
}
21492161

21502162
ret = dwc3_gadget_run_stop(dwc, is_on, false);
21512163
spin_unlock_irqrestore(&dwc->lock, flags);
2164+
pm_runtime_put(dwc->dev);
21522165

21532166
return ret;
21542167
}

0 commit comments

Comments
 (0)