From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Kuen-Han Tsai <khtsai@google.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH v4] usb: dwc3: Abort suspend on soft disconnect failure
Date: Tue, 22 Apr 2025 22:19:03 +0000 [thread overview]
Message-ID: <20250422221854.yl7ypzc4kkxbxw2a@synopsys.com> (raw)
In-Reply-To: <CAKzKK0pReSZeJ1-iRUbU=w+dK0O1fB7AgecfC7KJap6m5cQWnQ@mail.gmail.com>
On Tue, Apr 22, 2025, Kuen-Han Tsai wrote:
> On Tue, Apr 22, 2025 at 7:20 AM Thinh Nguyen <Thinh.Nguyen@synopsys.com> wrote:
> >
> > On Mon, Apr 21, 2025, Kuen-Han Tsai wrote:
> > > On Sat, Apr 19, 2025 at 9:24 AM Thinh Nguyen <Thinh.Nguyen@synopsys.com> wrote:
> > > >
> > > > On Wed, Apr 16, 2025, Kuen-Han Tsai wrote:
> >
> > <snip>
> >
> > > > > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> > > > > index 89a4dc8ebf94..630fd5f0ce97 100644
> > > > > --- a/drivers/usb/dwc3/gadget.c
> > > > > +++ b/drivers/usb/dwc3/gadget.c
> > > > > @@ -4776,26 +4776,22 @@ int dwc3_gadget_suspend(struct dwc3 *dwc)
> > > > > int ret;
> > > > >
> > > > > ret = dwc3_gadget_soft_disconnect(dwc);
> > > > > - if (ret)
> > > > > - goto err;
> > > > > -
> > > > > - spin_lock_irqsave(&dwc->lock, flags);
> > > > > - if (dwc->gadget_driver)
> > > > > - dwc3_disconnect_gadget(dwc);
> > > > > - spin_unlock_irqrestore(&dwc->lock, flags);
> > > > > -
> > > > > - return 0;
> > > > > -
> > > > > -err:
> > > > > /*
> > > > > * Attempt to reset the controller's state. Likely no
> > > > > * communication can be established until the host
> > > > > * performs a port reset.
> > > > > */
> > > > > - if (dwc->softconnect)
> > > > > + if (ret && dwc->softconnect) {
> > > > > dwc3_gadget_soft_connect(dwc);
> > > > > + return -EAGAIN;
> > > >
> > > > This may make sense to have -EAGAIN for runtime suspend. I supposed this
> > > > should be fine for system suspend since it doesn't do anything special
> > > > for this error code.
> > > >
> > > > When you tested runtime suspend, did you observe that the device
> > > > successfully going into suspend on retry?
> > >
> > > Hi Thinh,
> > >
> > > Yes, the dwc3 device can be suspended using either
> > > pm_runtime_suspend() or dwc3_gadget_pullup(), the latter of which
> > > ultimately invokes pm_runtime_put().
> > >
> > > One question: Do you know how to naturally cause a run stop failure?
> > > Based on the spec, the controller cannot halt until the event buffer
> > > becomes empty. If the driver doesn't acknowledge the events, this
> > > should lead to the run stop failure. However, since I cannot naturally
> > > reproduce this problem, I am simulating this scenario by modifying
> > > dwc3_gadget_run_stop() to return a timeout error directly.
> > >
> >
> > I'm not clear what you meant by "naturally" here. The driver is
> > implemented in such a way that this should not happen. If it does, we
> > need to take look to see what we missed.
> >
> > However, to force the driver to hit the controller halt timeout, just
> > wait/generate some events and don't clear the GEVNTCOUNT of event bytes
> > before clearing the run_stop bit.
> >
> > BR,
> > Thinh
>
> Hi Thinh,
>
> Thank you for getting back to me and the method to force the timeout!
>
> By "naturally," I meant reproducing the issue without artificial steps
Ok.
> designed solely to trigger it. You're right; since the driver is
> designed to prevent this state, reproducing it "naturally" is
> difficult.
>
> I really appreciate your patience, and thank you once more for the
> helpful clarification.
>
You're welcome.
BR,
Thinh
next prev parent reply other threads:[~2025-04-22 22:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 10:05 [PATCH v4] usb: dwc3: Abort suspend on soft disconnect failure Kuen-Han Tsai
2025-04-19 1:24 ` Thinh Nguyen
2025-04-21 11:25 ` Kuen-Han Tsai
2025-04-21 23:20 ` Thinh Nguyen
2025-04-22 15:50 ` Kuen-Han Tsai
2025-04-22 22:19 ` Thinh Nguyen [this message]
2025-05-28 7:35 ` Kuen-Han Tsai
2025-05-28 8:21 ` gregkh
2025-05-28 10:07 ` Kuen-Han Tsai
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=20250422221854.yl7ypzc4kkxbxw2a@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=gregkh@linuxfoundation.org \
--cc=khtsai@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@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