Skip to content

Commit c0aabed

Browse files
Krishna Kurapatigregkh
authored andcommitted
usb: dwc3: gadget: Propagate core init errors to UDC during pullup
In scenarios where pullup relies on resume (get sync) to initialize the controller and set the run stop bit, then core_init is followed by gadget_resume which will eventually set run stop bit. But in cases where the core_init fails, the return value is not sent back to udc appropriately. So according to UDC the controller has started but in reality we never set the run stop bit. On systems like Android, there are uevents sent to HAL depending on whether the configfs_bind / configfs_disconnect were invoked. In the above mentioned scnenario, if the core init fails, the run stop won't be set and the cable plug-out won't result in generation of any disconnect event and userspace would never get any uevent regarding cable plug out and we never call pullup(0) again. Furthermore none of the next Plug-In/Plug-Out's would be known to configfs. Return back the appropriate result to UDC to let the userspace/ configfs know that the pullup failed so they can take appropriate action. Fixes: 77adb8b ("usb: dwc3: gadget: Allow runtime suspend if UDC unbinded") Cc: stable <stable@kernel.org> Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com> Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Message-ID: <20230618120949.14868-1-quic_kriskura@quicinc.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0e5342f commit c0aabed

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/usb/dwc3/gadget.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2747,7 +2747,9 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
27472747
ret = pm_runtime_get_sync(dwc->dev);
27482748
if (!ret || ret < 0) {
27492749
pm_runtime_put(dwc->dev);
2750-
return 0;
2750+
if (ret < 0)
2751+
pm_runtime_set_suspended(dwc->dev);
2752+
return ret;
27512753
}
27522754

27532755
if (dwc->pullups_connected == is_on) {

0 commit comments

Comments
 (0)