dwc2 usb driver does not handle disconnect in gadget mode correctly, this results in the gadget still thinking it is connected to a host. Changing the suspend interrupt handling in gadget mode to reflect the correct disconnected state fixes this. Cc: linux-usb@xxxxxxxxxxxxxxx <linux-usb@xxxxxxxxxxxxxxx> Cc: Minas Harutyunyan <hminas@xxxxxxxxxxxx> Signed-off-by: Adrian Carpenter <adrian@xxxxxxxxxxxx> --- drivers/usb/dwc2/core_intr.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff -uprN -X usb-vanilla/Documentation/dontdiff usb-vanilla/drivers/usb/dwc2/core_intr.c usb/drivers/usb/dwc2/core_intr.c --- usb-vanilla/drivers/usb/dwc2/core_intr.c 2020-01-13 13:56:03.988950132 +0000 +++ usb/drivers/usb/dwc2/core_intr.c 2020-01-13 17:29:03.496377075 +0000 @@ -536,13 +536,12 @@ static void dwc2_handle_usb_suspend_intr } skip_power_saving: /* - * Change to L2 (suspend) state before releasing - * spinlock + * Suspend seems to be called in then event + * of gadget mode disconnect */ - hsotg->lx_state = DWC2_L2; + hsotg->lx_state = DWC2_L3; - /* Call gadget suspend callback */ - call_gadget(hsotg, suspend); + usb_gadget_set_state(&hsotg->gadget, USB_STATE_NOTATTACHED); } } else { if (hsotg->op_state == OTG_STATE_A_PERIPHERAL) {