On 8/4/23 19:01, Miquel Raynal wrote:
Hi Tom,

Well, what's needed / is it possible to get to the point where we don't
_need_ to call bind/unbind for each of these cases? Is there something
we're supposed to be setting in the DT that we aren't?

You do need to unbind the ethernet before using fastboot, always, with the 
'unbind ethernet 0', you dont need the peripheral unbind/rebind part, so it 
should behave like before.

And for my own understanding, why don't we need to bind a fastboot
gadget?

The fastboot command does that internally .

This is not visible with dm tree and I did not find how to bind the
fastboot gadget manually.

This makes the CLI clearly uneven and the internal code badly different
between gadgets/commands. Why can't we have them both
autoloaded/unloaded like before? I think I missed something which
explains the rationale behind this series.

They aren't both auto-loaded currently. We have a legacy call,
usb_ether_init(), in a few cases, so that gadget mode ethernet starts.
But this leads to the ref counting problems you encountered and
re-posted the rejected series for.

Ok, thanks for the additional details.

I don't understand why fastboot autoloads the correct gadget driver if
there is none bound, while all network commands just fail to do that if
we don't make the usb_ether_init() call manually.

Look into cmd/fastboot.c , it does usb_gadget_initialize(0) , just like usb_ether_init() does.

I also don't understand why I need to unbind the ethernet gadget but I
cannot bind the fastboot gadget.

Look into cmd/fastboot.c , it does usb_gadget_release() at the end of its operation, just like usb_eth_unbind() which is triggered by the bind/unbind commands.

My underlying question is: can we have a single approach for all
drivers, or is it too complex today? Could it be possible, when we
perform these autoloads, to look up the registered gadget and
potentially unbind the one already in place before?

The usb ethernet is special as there is no "ethernet" command like the "fastboot" command , which is why it has to be special handled by the bind/unbind commands.

Reply via email to