Discussion:
usbtest and pattern=1
Matthieu CASTET
2008-01-15 08:53:34 UTC
Permalink
Hi,

I am trying to use usbtest and g_zero to do some device driver test
(http://www.linux-usb.org/usbtest/).

I have some question about usbtest and g_zero with pattern=1.


pattern=1 imply mod63 test and the buffer received. This allow to catch
case were we lose packet.

* But when the test start, on the host set_altsetting will be called.
This will on the device call zero_set_config which will do a :
- zero_reset_config (do usb_ep_disable)
- set_source_sink_config (do usb_ep_enable & usb_ep_queue)

But most gadget drivers flush their fifo on usb_ep_enable or when there
is nothing in the queue.
So if on the host we send data on the bulk endpoint after the
set_altsetting but the device isn't fast enough, the usb_ep_enable &
usb_ep_queue won't be done and we can lose packet due to the flush.

How the sync between host and device is supposed to work ?
Is ok for device driver to do flush on usb_ep_enable ?



* Also with pattern mode there need to be a sync between host and device
and sending several packets [1]. So this mean in this mode we should
either make sure there is short packet or either choose a correct buflen
for g_zero ?


* Is there some tests that use loopback mode of g_zero ?


Thanks,

Matthieu CASTET

[1]
/* mod63 stays in sync with short-terminated transfers,
* or otherwise when host and gadget agree on how large
* each usb transfer request should be. resync is done
* with set_interface or set_config.
*/

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
David Brownell
2008-01-15 09:51:04 UTC
Permalink
Post by Matthieu CASTET
Hi,
I am trying to use usbtest and g_zero to do some device driver test
(http://www.linux-usb.org/usbtest/).
I have some question about usbtest and g_zero with pattern=1.
That's a handy test mode that's certainly turned up bugs ... but
unfortunately it's awkward to set up and use, so it doesn't get
used as much as would be good.
Post by Matthieu CASTET
pattern=1 imply mod63 test and the buffer received. This allow to catch
case were we lose packet.
* But when the test start, on the host set_altsetting will be called.
- zero_reset_config (do usb_ep_disable)
- set_source_sink_config (do usb_ep_enable & usb_ep_queue)
But most gadget drivers flush their fifo on usb_ep_enable
The peripheral controller driver should do that instead. You'll
note that in the USB spec, "configuration" events (SET_CONFIGURATION
and SET_INTERFACE/altsetting) leave endpoints in a known state,
and they're the only times at which you can activate endpoints.
That state involves no traffic in-flight, and data toggles in
a defined state for non-iso endpoints).
Post by Matthieu CASTET
or when there is nothing in the queue.
Nothing in the queue? That would be a bug. It's perfectly legit
to send some data and then wait a while before sending more of it.
And neither data in the FIFO nor the endpoint data toggle should
change if there's no intervening config change event, regardless
of how full (or empty) the queue is.
Post by Matthieu CASTET
So if on the host we send data on the bulk endpoint after the
set_altsetting but the device isn't fast enough, the usb_ep_enable &
usb_ep_queue won't be done and we can lose packet due to the flush.
How the sync between host and device is supposed to work ?
The peripheral doesn't return from SET_INTERFACE (set_altsetting)
until after the endpoints are enabled.
Post by Matthieu CASTET
Is ok for device driver to do flush on usb_ep_enable ?
Gadget driver shouldn't do that, since the peripheral controller
driver should be doing it instead.
Post by Matthieu CASTET
* Also with pattern mode there need to be a sync between host and device
and sending several packets [1]. So this mean in this mode we should
either make sure there is short packet or either choose a correct buflen
for g_zero ?
Yes.
Post by Matthieu CASTET
* Is there some tests that use loopback mode of g_zero ?
NetChip had some windows-based tests using that mode.
I'm not sure there were ever any Linux-based ones.
Feel free to write and submit some. :)

- Dave
Post by Matthieu CASTET
Thanks,
Matthieu CASTET
[1]
/* mod63 stays in sync with short-terminated transfers,
* or otherwise when host and gadget agree on how large
* each usb transfer request should be. resync is done
* with set_interface or set_config.
*/
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Alan Stern
2008-01-15 15:32:34 UTC
Permalink
Post by David Brownell
Post by Matthieu CASTET
So if on the host we send data on the bulk endpoint after the
set_altsetting but the device isn't fast enough, the usb_ep_enable &
usb_ep_queue won't be done and we can lose packet due to the flush.
How the sync between host and device is supposed to work ?
The peripheral doesn't return from SET_INTERFACE (set_altsetting)
until after the endpoints are enabled.
At a lower level, the peripheral doesn't ACK the Status stage of the
Set-Interface request until all the operations (re-enabling endpoints,
flushing fifos, etc.) are finished. The gadget driver insures this by
not returning from its setup routine until everything is ready.

Alan Stern


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Matthieu CASTET
2008-01-17 09:24:27 UTC
Permalink
Hi,

Thanks for your quick reply.
Post by David Brownell
Post by Matthieu CASTET
Hi,
[...]
Post by David Brownell
Post by Matthieu CASTET
So if on the host we send data on the bulk endpoint after the
set_altsetting but the device isn't fast enough, the usb_ep_enable &
usb_ep_queue won't be done and we can lose packet due to the flush.
How the sync between host and device is supposed to work ?
The peripheral doesn't return from SET_INTERFACE (set_altsetting)
until after the endpoints are enabled.
Ok.


So it is my gadget driver that is buggy (s3c2410_udc).
I manage to fix this rewriting a driver based on lh7a40x_udc, but in the
process I broke some ctrl test.
So I have still work do to.



Matthieu


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Loading...