public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Tom Rini <trini@konsulko.com>
Cc: Marek Vasut <marex@denx.de>,
	u-boot@lists.denx.de, Kevin Hilman <khilman@baylibre.com>,
	Lukasz Majewski <lukma@denx.de>, Simon Glass <sjg@chromium.org>
Subject: Re: [PATCH v4 1/4] cmd: bind: Add unbind command with driver filter
Date: Fri, 4 Aug 2023 21:38:13 +0200	[thread overview]
Message-ID: <20230804213813.37f47528@xps-13> (raw)
In-Reply-To: <20230804185107.GZ3630934@bill-the-cat>

Hi Tom,

trini@konsulko.com wrote on Fri, 4 Aug 2023 14:51:07 -0400:

> On Fri, Aug 04, 2023 at 08:01:56PM +0200, Miquel Raynal wrote:
> > Hi Tom,
> > 
> > trini@konsulko.com wrote on Fri, 4 Aug 2023 13:20:29 -0400:
> >   
> > > On Fri, Aug 04, 2023 at 07:01:46PM +0200, 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.    
> > > 
> > > Because "fastboot" or "dfu" are both being told (as part of their call)
> > > "find usb gadget controller number X".  That's doing the bind.  Calling
> > > usb_ether_init just takes the first controller and that's that (and so
> > > could be / is wrong depending on the platform).  
> > 
> > This makes total sense, thanks for pointing it out.
> >   
> > > > I also don't understand why I need to unbind the ethernet gadget but I
> > > > cannot bind the fastboot gadget.    
> > > 
> > > You can't bind fastboot while ethernet is still configured.  
> > 
> > I guess "before this series", the ethernet would not be kept
> > configured, because I could use both fastboot and ethernet without
> > caring about which driver had to be bound. And that's maybe what lead to
> > the bug reports also. So you want to get rid of this. Do I get the
> > situation right now?  
> 
> We're getting rid of this path because it leads to failures, yes.
> 
> > >  It's in
> > > use.  And we aren't a full blown operating system with the logic to have
> > > multiple end points and devices configured and exposed.  I mean heck, we
> > > don't keep the gadget interface up between network calls so on the host
> > > side you need to re-configure the interface (or have something that's
> > > bringing it up there again each time).  Which is why DFU or fastboot or
> > > other "treat USB like USB" options tend to be more popular than "treat
> > > USB like ethernet" work flows.  
> > 
> > Yes of course.
> >   
> > > > 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?    
> > > 
> > > I would invite you to look in to this, yes.  
> > 
> > Sounds reasonably complex now, with the reasoning you made above.
> >   
> > >  No one objects to enhancing
> > > the code, but the "functionality" you see on am33xx is as you've also
> > > seen very broken in other ways, which is why it's not used virtually
> > > anywhere else and instead the "bind" command is.  For example, if you
> > > wanted to do this workflow on the new beagle devices, that's DWC3 and
> > > where the "bind" command came from :)  
> > 
> > Again to be very clear, while I felt misunderstood at the beginning and
> > did not accept Marek's series because it was replacing a data abort
> > with a non-functional setup, I now get a better understanding of the
> > problem (I believe) and, as said before, I am always in favor of
> > writing better code, easier to maintain, clearer to review. I am in
> > favor of such change. I just want the user life to be eased when this
> > happens if we break the CLI. So if you think the right approach is to
> > get rid of the usb_ether_init() call, alright, let's drop it off. But
> > we should not let the users in the dark by providing proper doc or
> > error messages which should compensate the extra step now required.  
> 
> I think it would be good if you posted a patch to update
> doc/board/ti/am335x_evm.rst to explain how to use the various gadget
> device cases.

Good idea, I've tried something.

Thanks,
Miquèl

  reply	other threads:[~2023-08-04 19:38 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-02 12:46 [PATCH v4 1/4] cmd: bind: Add unbind command with driver filter Marek Vasut
2023-08-02 12:46 ` [PATCH v4 2/4] usb: gadget: ether: Inline functions used once Marek Vasut
2023-08-02 12:46 ` [PATCH v4 3/4] usb: gadget: ether: Move probe function above driver structure Marek Vasut
2023-08-02 12:46 ` [PATCH v4 4/4] usb: gadget: ether: Handle gadget driver registration in probe and remove Marek Vasut
2023-08-02 21:31 ` [PATCH v4 1/4] cmd: bind: Add unbind command with driver filter Simon Glass
2023-08-02 22:04   ` Marek Vasut
2023-08-04  7:00 ` Miquel Raynal
2023-08-04 14:42   ` Marek Vasut
2023-08-04 15:01     ` Tom Rini
2023-08-04 15:05       ` Marek Vasut
2023-08-04 15:12         ` Miquel Raynal
2023-08-04 15:40           ` Marek Vasut
2023-08-04 16:00             ` Miquel Raynal
2023-08-04 16:15               ` Tom Rini
2023-08-04 17:01                 ` Miquel Raynal
2023-08-04 17:18                   ` Marek Vasut
2023-08-04 17:20                   ` Tom Rini
2023-08-04 18:01                     ` Miquel Raynal
2023-08-04 18:51                       ` Tom Rini
2023-08-04 19:38                         ` Miquel Raynal [this message]
2023-08-04 16:37               ` Tom Rini
2023-08-04 17:04                 ` Miquel Raynal
2023-08-04 17:19                   ` Marek Vasut
2023-08-04 17:23                   ` Tom Rini
2023-08-04 17:24             ` Miquel Raynal
2023-08-04 17:31               ` Marek Vasut
2023-08-04 17:46                 ` Miquel Raynal
2023-08-04 17:54                   ` Marek Vasut

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=20230804213813.37f47528@xps-13 \
    --to=miquel.raynal@bootlin.com \
    --cc=khilman@baylibre.com \
    --cc=lukma@denx.de \
    --cc=marex@denx.de \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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