linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] USB: dwc2: handle gadget mode disconnect correctly
@ 2020-01-13 18:20 Adrian Carpenter
  2020-01-15  7:45 ` Minas Harutyunyan
  0 siblings, 1 reply; 2+ messages in thread
From: Adrian Carpenter @ 2020-01-13 18:20 UTC (permalink / raw)
  To: linux-usb, hminas

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@vger.kernel.org <linux-usb@vger.kernel.org>
Cc: Minas Harutyunyan <hminas@synopsys.com>
Signed-off-by: Adrian Carpenter <adrian@fizzyade.com>
---
 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) {

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-15  7:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-13 18:20 [PATCH] USB: dwc2: handle gadget mode disconnect correctly Adrian Carpenter
2020-01-15  7:45 ` Minas Harutyunyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).