linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Carpenter <adrian@fizzyade.com>
To: linux-usb@vger.kernel.org, hminas@synopsys.com
Subject: [PATCH] USB: dwc2: handle gadget mode disconnect correctly
Date: Mon, 13 Jan 2020 18:20:09 +0000	[thread overview]
Message-ID: <CABBSF+K5J0zo9JaACQ5xY-Cis8bARqLdRuk4YVFLrM8GG0BhQQ@mail.gmail.com> (raw)

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) {

             reply	other threads:[~2020-01-13 18:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-13 18:20 Adrian Carpenter [this message]
2020-01-15  7:45 ` [PATCH] USB: dwc2: handle gadget mode disconnect correctly Minas Harutyunyan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABBSF+K5J0zo9JaACQ5xY-Cis8bARqLdRuk4YVFLrM8GG0BhQQ@mail.gmail.com \
    --to=adrian@fizzyade.com \
    --cc=hminas@synopsys.com \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).