Re: [PATCH] usb: Allow USB device to be warm reset in suspended state

From: BjÃrn Mork
Date: Wed Nov 06 2019 - 06:24:06 EST


Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> writes:

> I was sure I remembered reading somewhere that suspended devices were
> not allowed to be reset, but now I can't find that requirement anywhere
> in the USB spec.

I don't know anything about this, but "Reset From Suspended State" is
part of Appendix C in the USB 2.0 spec. Looks valid to me..

Quoting the relevant section for those who don't have that spec at hand:


C.2.1 Reset From Suspended State

As can be seen from Figure C-2, the device wakes up from the Suspended
state as soon as it sees a K or an SE0 on the bus. A J would be
indistinguishable from idle on the bus that a suspended device sees
normally. On seeing a K, the device will initiate a resume
process. For the details of this process, see Section 7.1.7.7. On
seeing an SE0, the device could enter the reset handshake procedure,
so it starts timer T0.

The actual reset handshake is only started after seeing a continuous
assertion of SE0 for at least 2.5 Îs (T FILTSE0 ). The loop between
the blocks with âClear timer T1â and âRun timer T1â represents this
filtering. If the device has not detected a continuous SE0 before
timer T0 exceeds the value of T UCHEND - T UCH , the device goes back
into the Suspended state.

A device coming from suspend most probably had its high-speed clock
stopped to meet the power requirements for a suspended device (see
Section 7.2.3). Therefore, it may take some time to let the clock
settle to a level of operation where it is able to perform the reset
detection and handshake with enough precision. In the state diagram, a
time symbol T WTCLK is used to have the device wait for a stable
clock. This symbol is not part of the USB 2.0 specification and does
not appear in Chapter 7. It is an implementation specific detail of
the reset detection state diagram for the upstream facing port, where
it is marked with a asterisk (*). T WTCLK should have a value
somewhere between 0 and 5.0 ms. This allows at least 1.0 ms time to
detect the continuous SE0.

If the device has seen an SE0 signal on the bus for at least T FILTSE0
, then it can safely assume to have detected a reset and can start the
reset handshake.




BjÃrn