From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Felipe Balbi <balbi@kernel.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
Michal Nazarewicz <mina86@mina86.com>
Subject: Re: Virtual hub, resets etc...
Date: Sat, 06 Jul 2019 08:06:08 +1000 [thread overview]
Message-ID: <61c9671f04cbbc085c8919430d92c7b2803378af.camel@kernel.crashing.org> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1907051008580.1606-100000@iolanthe.rowland.org>
On Fri, 2019-07-05 at 10:20 -0400, Alan Stern wrote:
>
> > Right. I do see the resume coming in, but I don't forward it to the
> > gadget because here's what happens in that order:
> >
> > 1- Host gets shutdown (or cable disconnected)
> >
> > 2- Upstream bus suspend: I call ->suspend on the gadgets on all
> > enabled ports that don't have USB_PORT_STAT_SUSPEND already set. I
> > don't change the port status, I don't set USB_PORT_STAT_SUSPEND
>
> Hmmm. Does the descriptor for your hub say that it is self-powered? A
> bus-powered hub would turn off completely when its upstream cable was
> unplugged, thereby sending a disconnect signal to all its child
> devices.
>
> I don't recall what the USB spec says a self-powered hub should do.
> Maybe it doesn't say anything about it.
Yes it's self powered. I took the cable as an example, this scenario
happens with a host power off as well of course whihc is more relevant
in our case since we are a BMC).
> > 3- Machine gets turned back on (or cable reconnected)
> >
> > 4- Upstream bus resume: I call ->resume on the gadgets on all
> > enabled ports that don't have USB_PORT_STAT_SUSPEND set.
>
> No, the upstream bus doesn't resume upon cable reconnect.
It does. At least my HW detects a resume signaling right before the but
reset.
> A resume
> would require packets to be received over the cable, but the host won't
> send any packets to the hub until the upstream port has been reset and
> enabled. So you should eliminate this step.
It's not a step I created. I do observe resume signaling by the hub HW
(it's an interrupt) right before the bus reset when the host comes back
up. In any case, no impact on what happens below...
> > 5- Upstream bus reset: I call ->suspend on all enabled ports after
> > clearing their status (I preserve only USB_PORT_STAT_SUSPEND and
> > USB_PORT_STAT_POWER which is always set for me). Note: I currently do
> > this even if the port had USB_PORT_STAT_SUSPEND set, so such as port
> > will get a double suspend ... maybe I shouldn't.
>
> I believe the upstream reset should cause the hub to clear all the
> downstream port statuses. Even if the reset doesn't do this, the
> Set-Config request which follows the reset should.
>
> Whether you tell the gadget drivers they are no longer suspended is up
> to you. I suspect it doesn't matter much.
Typo. I preserve POWER and CONNECTION. Not SUSPEND.
POWER because I'm self powered so it's always set and CONNECTION for
obvious reasons.
> > 6- Hosts sets port reset: I reset the gadget since it's already
> > bound/enabled. It's still "suspended".
> >
> > So we do have a legitimate case of "reset while suspended".
>
> Ah, but it doesn't contradict what I wrote earlier. There's a
> difference between resuming a suspended _device_ and resuming a
> suspended _port_.
>
> Nevertheless, in practice the difference doesn't matter and the
> composite core should do the right thing.
Yes :-)
> > I'll tidy up the patch and submit it.
>
> Good.
Cheers,
Ben.
next prev parent reply other threads:[~2019-07-05 22:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-04 5:52 Virtual hub, resets etc Benjamin Herrenschmidt
2019-07-04 8:02 ` f_mass_storage configuration races (Was: Virtual hub, resets etc...) Benjamin Herrenschmidt
2019-07-04 8:04 ` [PATCH] usb: gadget: mass_storage: Fix races between fsg_disable and fsg_set_alt Benjamin Herrenschmidt
2019-07-04 16:13 ` Virtual hub, resets etc Alan Stern
2019-07-04 21:44 ` Benjamin Herrenschmidt
2019-07-04 21:58 ` Benjamin Herrenschmidt
2019-07-05 1:37 ` Alan Stern
2019-07-05 2:15 ` Benjamin Herrenschmidt
2019-07-05 14:20 ` Alan Stern
2019-07-05 22:06 ` Benjamin Herrenschmidt [this message]
2019-07-05 1:34 ` Alan Stern
2019-07-05 2:08 ` Benjamin Herrenschmidt
2019-07-05 14:08 ` Alan Stern
2019-07-05 22:01 ` Benjamin Herrenschmidt
2019-07-06 18:37 ` Alan Stern
2019-07-06 23:44 ` Benjamin Herrenschmidt
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=61c9671f04cbbc085c8919430d92c7b2803378af.camel@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--cc=balbi@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mina86@mina86.com \
--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).