Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5C185C001DE for ; Fri, 4 Aug 2023 16:15:27 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7D9A98679B; Fri, 4 Aug 2023 18:15:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="eCOYVrt0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5BD088679B; Fri, 4 Aug 2023 18:15:24 +0200 (CEST) Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 888CF86362 for ; Fri, 4 Aug 2023 18:15:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-58653c9bed3so26074597b3.2 for ; Fri, 04 Aug 2023 09:15:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; t=1691165718; x=1691770518; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=q2wb8NEDpps34uuMa3JBp20UUhyqgRhiH02IRX8iU6I=; b=eCOYVrt0RMQX9JhqRHBlxeIZEAEWpel6Rc1aV0jcMf1wwzBhns+2UPbW5msDZyRAbO awKqB7KOPEoUOT8d5nRY2H3vZ1isdVA7xYNc18+v/RBbqhucSRs1M8J53TFTNojFLawr wNQtJ5z2+83hH7VPNbTgDSvTChnMY30n7owTE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691165718; x=1691770518; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=q2wb8NEDpps34uuMa3JBp20UUhyqgRhiH02IRX8iU6I=; b=gkINwowNZgZEAj8PW/qWSWP8pXZ2h4oYumWWah+9NopO5vtjTINkFXuC+tv62c/gpb r/Qk4QSKWtycffeU9qYmZh3triDpRr3nyA+kvncwD8FMqNxpMhFs4/hcoDVVTs2zYyoo 3q8g+1K65MjpxjIq9VJ7b44AycsTt2+xSPlqAx2Mc/nbGtcfiRMkJNMZcew/GNgaWmTY uNdSwcuwBSo+ZMxIYLguNB3Micga4/BWOXA25KCLGq+sn16DqYLyF7HRy9m4lngnAytA jApKcmCQU+9PJgqaQWfVHegYrVgYGm7zY0zNnh4DhwAKAYC3TPfnlxUM1pc0txIVMWpO LIRA== X-Gm-Message-State: AOJu0YyF+W7RyoEkl7fQzAaUn7aMA0VFF1QPL2GjKT1iru8beqcRIbTt H4rJrGPQQe0kZuP3JVlEXqDedA== X-Google-Smtp-Source: AGHT+IG8oRNTAO7xB4x9Dv9SSdUvMDosL22GOmERjuLnJOGH6PzxGzFuOZ3FJd354ijzTaR8FNLdyg== X-Received: by 2002:a0d:d4d1:0:b0:576:93f1:d120 with SMTP id w200-20020a0dd4d1000000b0057693f1d120mr2290840ywd.12.1691165718203; Fri, 04 Aug 2023 09:15:18 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b00-6400-c37f-6e0c-fce7-d587.res6.spectrum.com. [2603:6081:7b00:6400:c37f:6e0c:fce7:d587]) by smtp.gmail.com with ESMTPSA id w13-20020a81a20d000000b0057a05834754sm790994ywg.75.2023.08.04.09.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 09:15:17 -0700 (PDT) Date: Fri, 4 Aug 2023 12:15:15 -0400 From: Tom Rini To: Miquel Raynal Cc: Marek Vasut , u-boot@lists.denx.de, Kevin Hilman , Lukasz Majewski , Simon Glass Subject: Re: [PATCH v4 1/4] cmd: bind: Add unbind command with driver filter Message-ID: <20230804161515.GR3630934@bill-the-cat> References: <20230802124657.31184-1-marex@denx.de> <20230804090028.70aa780d@xps-13> <4833722f-18ab-e885-291a-988115fe39f8@denx.de> <20230804150100.GN3630934@bill-the-cat> <8902cf54-acba-cfb4-571b-09ba807e7a89@denx.de> <20230804171206.07faade4@xps-13> <0eb7f3fe-42da-6252-3b77-50eb3276f2ee@denx.de> <20230804180012.79c4f9ec@xps-13> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="BQ0LbchurJp5zPlI" Content-Disposition: inline In-Reply-To: <20230804180012.79c4f9ec@xps-13> X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean --BQ0LbchurJp5zPlI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 04, 2023 at 06:00:12PM +0200, Miquel Raynal wrote: > Hi Marek, >=20 > marex@denx.de wrote on Fri, 4 Aug 2023 17:40:07 +0200: >=20 > > On 8/4/23 17:12, Miquel Raynal wrote: > > > Hi, > > >=20 > > > marex@denx.de wrote on Fri, 4 Aug 2023 17:05:01 +0200: > > > =20 > > >> On 8/4/23 17:01, Tom Rini wrote: =20 > > >>> On Fri, Aug 04, 2023 at 04:42:13PM +0200, Marek Vasut wrote: =20 > > >>>> On 8/4/23 09:00, Miquel Raynal wrote: =20 > > >>>>> Hi Marek, > > >>>>> > > >>>>> marex@denx.de wrote on Wed, 2 Aug 2023 14:46:54 +0200: =20 > > >>>>> >>>>>> Extend the driver core to perform lookup by both OF node= and driver =20 > > >>>>>> bound to the node. Use this to look up specific device instances= to > > >>>>>> unbind from nodes in the unbind command. One example where this = is > > >>>>>> needed is USB peripheral controller, which may have multiple gad= get > > >>>>>> drivers bound to it. The unbind command has to select that speci= fic > > >>>>>> gadget driver instance to unbind from the controller, not unbind= the > > >>>>>> controller driver itself from the controller. > > >>>>>> > > >>>>>> USB ethernet gadget usage looks as follows with this change. Not= ice > > >>>>>> the extra 'usb_ether' addition in the 'unbind' command at the en= d. > > >>>>>> " > > >>>>>> bind /soc/usb-otg@49000000 usb_ether > > >>>>>> setenv ethact usb_ether > > >>>>>> setenv loadaddr 0xc2000000 > > >>>>>> setenv ipaddr 10.0.0.2 > > >>>>>> setenv serverip 10.0.0.1 > > >>>>>> setenv netmask 255.255.255.0 > > >>>>>> tftpboot 0xc2000000 10.0.0.1:test.file > > >>>>>> unbind /soc/usb-otg@49000000 usb_ether =20 > > >>>>> > > >>>>> This extra parameter does not seem to work on the BBBW. I cannot = select > > >>>>> the "usb_ether" driver like you do. > > >>>>> > > >>>>> Good news though, I am now able to use fastboot, but it is not > > >>>>> straightforward: > > >>>>> > > >>>>> Here is my sequence right after the boot (reducing the dm tree ou= tput > > >>>>> to the usb nodes for clarity): =20 > > >>>>> >>>>> =3D> dm tree =20 > > >>>>> misc 0 [ + ] ti-musb-wrapper | |-- usb@47= 400000 > > >>>>> usb 0 [ + ] ti-musb-peripheral | | |-- us= b@47401000 > > >>>>> ethernet 1 [ + ] usb_ether | | | `-= - usb_ether > > >>>>> bootdev 3 [ ] eth_bootdev | | | = `-- usb_ether.bootdev > > >>>>> usb 0 [ ] ti-musb-host | | `-- us= b@47401800 =20 > > >>>>> =3D> fastboot usb 0 =20 > > >>>>> couldn't find an available UDC > > >>>>> g_dnl_register: failed!, error: -19 =20 > > >>>> > > >>>> That is expected and not a bug, since the beagle explicitly binds = USB > > >>>> ethernet to MUSB gadget in board file, which is legacy deprecated = way. =20 > > >>> > > >>> So, we should do away with, probably all of arch_misc_init() in > > >>> arch/arm/mach-omap2/am33xx/board.c for the non-SPL case. =20 > > >> > > >> Yes > > >> =20 > > >>>>> exit not allowed from main input shell. =20 > > >>>>> =3D> unbind /ocp/usb@47400000/usb@47401000 usb_ether =20 > > >>>> > > >>>> Does =20 > > >>>> >>>> =3D> unbind ethernet 0 =20 > > >>>> > > >>>> work ? > > >>>> > > >>>> If so, 1/4 in this series can be skipped altogether. > > >>>> > > >>>> You likely won't even need the rebinding of ti-musb-peripheral any= more. =20 > >=20 > > Did you test this yet ? >=20 > Not yet, I'll send you the feedback once done. >=20 > > >>>>> Cannot find a device with path /ocp/usb@47400000/usb@47401000 =20 > > >>>>> =3D> unbind /ocp/usb@47400000/usb@47401000 > > >>>>> =3D> dm tree =20 > > >>>>> misc 0 [ + ] ti-musb-wrapper | |-- usb@47= 400000 > > >>>>> usb 0 [ ] ti-musb-host | | `-- us= b@47401800 =20 > > >>>>> =3D> fastboot usb 0 > > >>>>> =3D> bind /ocp/usb@47400000/usb@47401000 ti-musb-peripheral > > >>>>> =3D> dm tree =20 > > >>>>> misc 0 [ + ] ti-musb-wrapper | |-- usb@47= 400000 > > >>>>> usb 0 [ ] ti-musb-host | | |-- us= b@47401800 > > >>>>> usb 0 [ ] ti-musb-peripheral | | `-- us= b@47401000 =20 > > >>>>> =3D> fastboot usb 0 =20 > > >>>>> musb-hdrc: peripheral reset irq lost! > > >>>>> # works! (the irq-related line above as always been there) > > >>>>> > > >>>>> So now, how do we make this process easy/understandable? =20 > > >>>> > > >>>> What would be your proposal ? =20 > > >=20 > > > At least I would appreciate: > > > - to select CMD_BIND "by default" when relevant > > > - to make the fastboot error more readable for the regular user =20 > >=20 > > Since with this 'unbind ethernet 0' this is orthogonal to this series, = send separate patches, thanks. >=20 > This is not orthogonal, I am sorry. >=20 > version X: > - tftp works "out of the box" > - fastboot works "out of the box" > version X+1: > - tftp works "out of the box" > - fastboot returns an obscure error >=20 > 1/ If we now *need* the bind/unbind commands, the series must take care > of it. > 2/ Without proper error message you just break fastboot for most > regular users (basically everyone but few U-Boot devs). >=20 > > > If you want to get rid of all the legacy code, I am not opposed, > > > really, but that must not be the user who is responsible for > > > understanding what changed in the "core". It must be very easily > > > accessible to understand that now: > > > - manual binding/unbinding is needed > > > - which driver must be used when =20 > >=20 > > When my spare time permits. >=20 > I understand. But I strongly disagree with this approach. We want to > make U-Boot better. I am fine with all internal changes you wish, even > if it breaks the CLI at some point because it is more accurate and > drops a ton of legacy code. Again, this is okay as long as the CLI > tells the user what changed in the behavior. So when I run > tftp/dhcp/ping/whatever, if you don't want to automatically bind the > ethernet gadget I'm okay, but just tell the user "Please make sure the > Ethernet gadget is bound, eg: unbind xxx; bind yyy" (possibly giving > automatic shortcuts to avoid the pain of finding the path of the > controller). And when fastboot fails, same idea. >=20 > Could you please consider enhancing these parts as well? >=20 > > >>> Well, what's needed / is it possible to get to the point where we d= on't > > >>> _need_ to call bind/unbind for each of these cases? Is there someth= ing > > >>> we're supposed to be setting in the DT that we aren't? =20 > > >> > > >> You do need to unbind the ethernet before using fastboot, always, wi= th the 'unbind ethernet 0', you dont need the peripheral unbind/rebind part= , so it should behave like before. =20 > > >=20 > > > And for my own understanding, why don't we need to bind a fastboot > > > gadget? =20 > >=20 > > The fastboot command does that internally . >=20 > This is not visible with dm tree and I did not find how to bind the > fastboot gadget manually. >=20 > 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. --=20 Tom --BQ0LbchurJp5zPlI Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmTNJBMACgkQFHw5/5Y0 tyyQowv+KO9Ron0R8XlTd1EpyJxV8pV10qtsB4GbAqPm/t4CwnnlGup1o8/NuttM yqEg+TKvJHDb93RAYNTyuUxGMIFNic1BPqIAOVhqsOo2K9id4qnmp/AJoxmh2Rou Ze2sz4K7IbsxfIqexxYmBerblHEYDQw6g1nVGeja8JA2ylhNqfkY/e3X9wkdPqL/ dTPB/1vum91Twlyr4kVEh4RahZPyOck93yFd9fg1eZflxLkEL6GQjqvwIBwOfGn8 8WhzIhWOQT6LFBD/ZARV0rEyiKGI8RYm6VkAVpblobr8enmI0hkxJD9SNh70znpq FPg6jYQUdFhU6osP7yrThHGwnitTOvtr1xEIcVoRlzLwW5DLtu74L06B6PfVvGbQ TI43lsbPKmLSx4cdt0b+ZbSDzOCeEQNMI1ZDR/SBeAhQTiFInFvE++AqqKlO54EH pVX5UEsP01ph1cShBK19fmKCyd7YrAJblOwrYMkMu0Z0ctdsUPmmngGFkUoZYxs6 o/PcK8x2 =CTap -----END PGP SIGNATURE----- --BQ0LbchurJp5zPlI--