From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Roger Quadros <rogerq@kernel.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: Re: dwc3: gadget suspend/resume vs system suspend/resume
Date: Thu, 16 Feb 2023 22:10:26 +0000 [thread overview]
Message-ID: <20230216221023.akjxerp7mltecjcy@synopsys.com> (raw)
In-Reply-To: <Y+6MJ2juVmPdp15q@rowland.harvard.edu>
On Thu, Feb 16, 2023, Alan Stern wrote:
> On Thu, Feb 16, 2023 at 06:11:36PM +0000, Thinh Nguyen wrote:
> > On Thu, Feb 16, 2023, Roger Quadros wrote:
> > > I could not find any reference to 500ms time limit for suspend/resume case.
> > > The only mention of 500ms in USB2.0 spec is:
> > >
> > > 9.2.6.4 Standard Device Requests
> > > ...
> > > For standard device requests that require data stage transfer
> > > to the host, the device must be able to return the first data
> > > packet to the host within 500 ms of receipt of the request.
> > > For subsequent data packets, if any, the device must be able to
> > > return them within 500 ms of successful completion of the
> > > transmission of the previous packet. The device must then be
> > > able to successfully complete the status stage within 50 ms after
> > > returning the last data packet.
> > >
> > > I don't think this applies to suspend/resume.
>
> It's not specific to suspend/resume; it's a generic time limit. It can
> vary depending on the application or the driver.
>
> > Are you referring to the handshake timeout when the host tries to
> > initiate resume at the link layer? It's relatively short compare to the
> > software timeout and will vary depending on how many hub tiers in the
> > topology. Also, that's handled by the host and device controller. We
> > should care more about the software timeout after resume completed. The
> > 500ms here applies if the device couldn't resume fast enough for the
> > driver to prepare a transfer response to the host.
>
> Also, keep in mind that we can increase the initial timeout limit
> following a resume, if necessary (on Linux hosts with a recent kernel --
> obviously not on other kinds of hosts). Or make it an adjustable
> parameter.
>
> > > > IMO, the system suspend on the gadget side should take precedence. That
> > > > is, it shouldn't depend on whether the usb gadget is in suspend or not
> > > > to go through system suspend. For that to happen, the gadget must
> > > > initiate soft-disconnect. Otherwise I can see we may run into
> > > > complications from the delay from the system suspend. For example, what
> > > > if the host initiates resume right after suspend while the gadget side
> > > > is still suspending?
> > >
> > > In this case, system will go all the way to suspend and then wake up.
> > > It will take a few seconds more to respond than if system was already suspended.
> >
> > Yes, my concern is the suspend/resume is measured in seconds.
>
> It the gadget is too slow in responding, it shouldn't be a big deal.
> The host will assume the gadget has disconnected and then will
> re-discover it. Pretty much the same as if the gadget had actually
> disconnected from the bus before going into system suspend.
>
It may not be the same. The host may try to recover and reset the
device. If it fails after a few tries, it will stop communicate with the
device until the next port change event. So the worst possible case
would require the user to reconnect the device to trigger a port change
event for the host to respond and reconnect the device. I'm not sure how
easy it can get to that point. This requires some testings.
BR,
Thinh
next prev parent reply other threads:[~2023-02-16 22:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-15 9:40 dwc3: gadget suspend/resume vs system suspend/resume Roger Quadros
2023-02-15 15:41 ` Alan Stern
2023-02-15 17:29 ` Roger Quadros
2023-02-15 18:24 ` Alan Stern
2023-02-15 22:53 ` Thinh Nguyen
2023-02-16 8:40 ` Roger Quadros
2023-02-16 18:11 ` Thinh Nguyen
2023-02-16 20:03 ` Alan Stern
2023-02-16 22:10 ` Thinh Nguyen [this message]
2023-02-16 20:43 ` Roger Quadros
2023-02-16 22:23 ` Thinh Nguyen
2023-02-17 9:28 ` Roger Quadros
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=20230216221023.akjxerp7mltecjcy@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=linux-usb@vger.kernel.org \
--cc=rogerq@kernel.org \
--cc=stern@rowland.harvard.edu \
/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).