On Fri, 15 Dec 2017, Felipe Balbi wrote: > > Hi, > > Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> writes: > > On Thu, 14 Dec 2017, Mathias Nyman wrote: > > > >> Clear Feature Endpoint Halt should reset the data toggle even if the > >> endpoint isn't halted. Host should manage to clear the host side data > >> toggle to keep in sync with the device. > >> > >> Test by sending a "3 data packet URB" before and after clearing the halt. > >> this should create a toggle sequence with two consecutive DATA0 packets. > >> > >> A successful test sequence looks like this > >> ClearFeature(ENDPOINT_HALT) - initial toggle clear > >> DATA0 (max packet sized) > >> DATA1 (max packet sized) > >> DATA0 (zero length packet) > >> ClearFeature(ENDPOINT_HALT) - resets toggle > >> DATA0 (max packet sized), if clear halt fails then toggle is DATA1 > >> DATA1 (max packet sized) > >> DATA0 (zero length packet) > >> > >> Signed-off-by: Mathias Nyman <mathias.nyman@xxxxxxxxxxxxxxx> > > > > This test is a little unusual in that it doesn't contain a way to > > detect failures. That is, you can't tell from the test results whether > > the device and the host behaved the way they are supposed to (in the > > case of the host, you could use a USB analyzer to find out). > > wouldn't we get EPIPE in cases where host's and device's data > toggle/seqNum go out of sync? No. When a device receives a packet with the wrong toggle value, it is supposed to return ACK and then ignore the packet contents (see section 8.6.4 in the USB-2 spec -- the device assumes the packet is a retransmission of one it already received). It doesn't return any sort of error token. If the device failed to reset its toggle to 0, the effect would be that it would ignore the data in the next packet. But since this test doesn't check whether or not the data gets ignored, it can't tell what really happened. > > Also, some devices don't handle Clear-Halt requests properly if the > > endpoint isn't already halted. Presumably people wouldn't use one of > > those devices for this test! :-) > > It's mandatory for devices to support Clear-Halt as means to reset data > toggle/SeqNum. If such controllers exist, they aren't certifiable IIRC. That's right. Nevertheless, plenty of such devices do exist. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html