From mboxrd@z Thu Jan 1 00:00:00 1970 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 0ACD0C04A6A for ; Wed, 2 Aug 2023 14:43:05 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3C26C8686E; Wed, 2 Aug 2023 16:43:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="GjLj3vzK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 55EB68682A; Wed, 2 Aug 2023 16:43:01 +0200 (CEST) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 05C708686E for ; Wed, 2 Aug 2023 16:42:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=miquel.raynal@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id D52A7C0003; Wed, 2 Aug 2023 14:42:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1690987377; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rJ6bSU5T9UFTHeadTVyx32/1C8jkkcuWsD87oGIVtWc=; b=GjLj3vzKC6FYBzuIDtMaojg6Xg7YJKjRxYcpeMnit63SWsf1aKqbnJM4WxrkcsDT5QPkLM x9x7skDT+QVvVpimx1MQigew6mGLFfzheVpscDqu/zBw9Ay+vK+LTjXVANJxBmlO62uj+s tA76NDEqjIpQ1KZ+59zXLFoeGbDdxWQwz6QT64Jkpb7cYEt3ZuqRN5GnmaH6/f6xefSQLe FAYLmKQMj6Y681NHC01wLAm0BHJGRjUuFWxeNkfPzn8pghhRscZ5D/MDEKyO/TVQHep+dk gIDSnwu2NgtfdJdK+xzKSlofwKbQfHqONO7v4G6hV1O0btjLSP1bc25efktToQ== Date: Wed, 2 Aug 2023 16:42:55 +0200 From: Miquel Raynal To: Marek Vasut Cc: u-boot@lists.denx.de, Kevin Hilman , Lukasz Majewski , Simon Glass Subject: Re: [PATCH v3 1/4] cmd: bind: Add unbind command with driver filter Message-ID: <20230802164255.3606247a@xps-13> In-Reply-To: <4c582a3e-9e82-fc77-a325-7b371691fcc4@denx.de> References: <20230729145712.213945-1-marex@denx.de> <20230731113159.26e710aa@xps-13> <20230731153607.6210e92f@xps-13> <8c31ee42-36c4-beab-853b-45f7828908a6@denx.de> <20230731155857.1575f5a4@xps-13> <830897a6-d061-f7c8-8f30-7ccc906b53a4@denx.de> <20230731162520.3897ba88@xps-13> <20230801205342.2fdbffc8@xps-13> <85b8d9a7-db07-429b-e880-677f575f05c7@denx.de> <20230802094802.736eb4dc@xps-13> <4c582a3e-9e82-fc77-a325-7b371691fcc4@denx.de> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: miquel.raynal@bootlin.com 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 Hi Marek, marex@denx.de wrote on Wed, 2 Aug 2023 16:38:47 +0200: > On 8/2/23 09:48, Miquel Raynal wrote: > > Hi Marek, > >=20 > > marex@denx.de wrote on Wed, 2 Aug 2023 01:07:46 +0200: > > =20 > >> On 8/1/23 20:53, Miquel Raynal wrote: =20 > >>> Hi Marek, > >>> > >>> marex@denx.de wrote on Mon, 31 Jul 2023 16:40:04 +0200: =20 > >>> >>>> On 7/31/23 16:25, Miquel Raynal wrote: =20 > >>>>> Hi Marek, > >>>>> > >>>>> marex@denx.de wrote on Mon, 31 Jul 2023 16:08:19 +0200: =20 > >>>>> >>>> On 7/31/23 15:58, Miquel Raynal wrote: =20 > >>>>>>> Hi Marek, > >>>>>>> > >>>>>>> marex@denx.de wrote on Mon, 31 Jul 2023 15:50:58 +0200: =20 > >>>>>>> >>>> On 7/31/23 15:36, Miquel Raynal wrote: =20 > >>>>>>>>> Hi Marek, > >>>>>>>>> > >>>>>>>>> marex@denx.de wrote on Mon, 31 Jul 2023 13:44:25 +0200: =20 > >>>>>>>>> >>>> On 7/31/23 11:31, Miquel Raynal wrote: =20 > >>>>>>>>>>> Hi Marek, > >>>>>>>>>>> > >>>>>>>>>>> marex@denx.de wrote on Sat, 29 Jul 2023 16:57:09 +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 insta= nces to > >>>>>>>>>>>> unbind from nodes in the unbind command. One example where t= his is > >>>>>>>>>>>> needed is USB peripheral controller, which may have multiple= gadget > >>>>>>>>>>>> drivers bound to it. The unbind command has to select that s= pecific > >>>>>>>>>>>> gadget driver instance to unbind from the controller, not un= bind the > >>>>>>>>>>>> controller driver itself from the controller. > >>>>>>>>>>>> > >>>>>>>>>>>> USB ethernet gadget usage looks as follows with this change.= Notice > >>>>>>>>>>>> the extra 'usb_ether' addition in the 'unbind' command at th= e end. > >>>>>>>>>>>> " > >>>>>>>>>>>> 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 > >>>>>>>>>>>> " > >>>>>>>>>>>> > >>>>>>>>>>>> Signed-off-by: Marek Vasut > >>>>>>>>>>>> --- =20 > >>>>>>>>>>> > >>>>>>>>>>> I am no longer getting wrong pointer dereferences, the SPL is= working in > >>>>>>>>>>> recovery mode, TFTP "File not found" errors are no longer a p= roblem and > >>>>>>>>>>> I did not experience any reset while tftp'ing regular files. > >>>>>>>>>>> > >>>>>>>>>>> One last remaining request on my side is the need for using f= astboot as > >>>>>>>>>>> well which does no longer work as-is: =20 > >>>>>>>>>>> >>> =3D> fastboot usb 0 =20 > >>>>>>>>>>> couldn't find an available UDC > >>>>>>>>>>> g_dnl_register: failed!, error: -19 > >>>>>>>>>>> exit not allowed from main input shell. > >>>>>>>>>>> > >>>>>>>>>>> Can you advise what bind/unbind command would be necessary he= re? =20 > >>>>>>>>>> > >>>>>>>>>> Either 'unbind usb_ether' or run 'dm tree' -> look up the path= to usb_ether in the tree (it will be hanging under usb_peripheral or some = such), and then use 'unbind '. =20 > >>>>>>>>> > >>>>>>>>> Nice `dm tree` command, never used it before. > >>>>>>>>> > >>>>>>>>> Even when I unbind usb_ether I still get the same error: =20 > >>>>>>>>> >>> =3D> unbind /ocp/usb@47400000/usb@47401000 =20 > >>>>>>>>> =3D> fastboot usb 0 =20 > >>>>>>>>> couldn't find an available UDC > >>>>>>>>> g_dnl_register: failed!, error: -19 > >>>>>>>>> exit not allowed from main input shell. > >>>>>>>>> > >>>>>>>>> Is there a specific gadget driver which I should bind again man= ually? =20 > >>>>>>>> > >>>>>>>> Can you share the output of dm tree before/after unbind ? > >>>>>>>> > >>>>>>>> fastboot should auto-bind to the right thing. =20 > >>>>>>> > >>>>>>> Ok. Apparently it does not, but I don't have any clue why. If you= want > >>>>>>> me to check something else I will. Here is the output: > >>>>>>> > >>>>>>> U-Boot 2023.07-00806-g979e7443428 (Jul 31 2023 - 11:17:06 +0200) = =20 > >>>>>> > >>>>>> [...] =20 > >>>>>> >>>>> watchdog 0 [ + ] omap3_wdt | |-= - wdt@44e35000 =20 > >>>>>>> misc 0 [ + ] ti-musb-wrapper | |-- usb@4= 7400000 > >>>>>>> usb 0 [ + ] ti-musb-peripheral | | |-- u= sb@47401000 > >>>>>>> ethernet 1 [ + ] usb_ether | | | `= -- usb_ether > >>>>>>> bootdev 3 [ ] eth_bootdev | | | = `-- usb_ether.bootdev > >>>>>>> usb 0 [ ] ti-musb-host | | `-- u= sb@47401800 > >>>>>>> ethernet 0 [ + ] eth_cpsw | |-- ether= net@4a100000 > >>>>>>> bootdev 2 [ ] eth_bootdev | | `-- e= thernet@4a100000.bootdev > >>>>>>> simple_bus 67 [ ] ti_sysc | |-- targe= t-module@53100000 > >>>>>>> simple_bus 68 [ ] ti_sysc | |-- targe= t-module@53500000 > >>>>>>> simple_bus 69 [ ] ti_sysc | `-- targe= t-module@56000000 > >>>>>>> clk 62 [ ] fixed_clock |-- clk_mcasp= 0_fixed > >>>>>>> bootstd 0 [ ] bootstd_drv |-- bootstd > >>>>>>> bootmeth 0 [ ] bootmeth_efi | |-- efi > >>>>>>> bootmeth 1 [ ] bootmeth_extlinux | |-- extli= nux > >>>>>>> bootmeth 2 [ ] bootmeth_pxe | |-- pxe > >>>>>>> bootmeth 3 [ ] vbe_simple | `-- vbe_s= imple > >>>>>>> timer 0 [ + ] omap_timer `-- timer@0 = =20 > >>>>>>> =3D> unbind /ocp/usb@47400000/usb@47401000 =20 > >>>>>> > >>>>>> The commit message of this patch contains the following example: > >>>>>> unbind /soc/usb-otg@49000000 usb_ether > >>>>>> so in your case, try > >>>>>> unbind /ocp/usb@47400000/usb@47401000 usb_ether =20 > >>>>> > >>>>> Does not work, unfortunately: =20 > >>>>> =3D> unbind /ocp/usb@47400000/usb@47401000 usb_ether =20 > >>>>> Cannot find a device with path /ocp/usb@47400000/usb@47401000 =20 > >>>>> =3D> unbind /ocp/usb@47400000/usb@47401000 =20 > >>>> > >>>> Did this even work before , i.e. without this series, if you were to= use USB ethernet first and then fastboot second (that sequence is importan= t) ? =20 > >>> > >>> Yes it did. =20 > >>> >>>> Can you debug this ? Basically the problem that happens is th= at if you run: =20 > >>>> unbind /ocp/usb@47400000/usb@47401000 > >>>> this unbind ti-musb-peripheral usb@47401000 instead of just unbinding > >>>> usb_ether usb_ether =20 > >>> > >>> True. =20 > >>> >>>> Maybe just try =20 > >>>> unbind usb_ether =20 > >>> >>> =3D> unbind usb_ether =20 > >>> unbind - Unbind a device from a driver > >>> > >>> Usage: > >>> unbind [] > >>> unbind > >>> unbind =20 > >>> >>>> or =20 > >>>> unbind usb_ether usb_ether =20 > >>> >>> =3D> unbind usb_ether usb_ether =20 > >>> usb_ether is not a valid uclass =20 > >>> >>>> ti-musb-peripheral usb@47401000 has to stay in the dm tree ou= tput after the unbind. Or maybe try =20 > >>>> > >>>> bind /ocp/usb@47400000/usb@47401000 ti-musb-peripheral =20 > >>> > >>> Indeed when we perform the unbind, ti-musb-peripheral is removed. Yes, > >>> binding it again like you advise makes it come back. =20 > >>> >>>> and then the fastboot thing =20 > >>> > >>> Unfortunately after binding it again, so with the following dm tree > >>> snippet: > >>> > >>> misc 0 [ + ] ti-musb-wrapper | |-- usb@47400000 > >>> usb 0 [ ] ti-musb-host | | |-- usb@474= 01800 > >>> usb 0 [ ] ti-musb-peripheral | | `-- usb@474= 01000 > >>> > >>> It still fails: =20 > >>> >>> =3D> fastboot usb 0 =20 > >>> couldn't find an available UDC > >>> g_dnl_register: failed!, error: -19 > >>> exit not allowed from main input shell. > >>> > >>> Without this series, this works: =20 > >>> =3D> unbind /ocp/usb@47400000/usb@47401000 > >>> =3D> bind /ocp/usb@47400000/usb@47401000 ti-musb-peripheral > >>> =3D> fastboot usb 0 =20 > >> > >> OK, so fastboot did not work even without this series without obscure = workarounds ? =20 > >=20 > > I'm happy you call the unbind/bind sequence an "obscure workaround" ;-) > >=20 > > The command "fastboot usb 0" works without your series, before tftp > > or after tftp, it does not matter, it used to work. Applying this > > series makes it always fail. > >=20 > > I was just reporting that, before your series, calling unbind would > > also remove ti-musb-peripheral, but calling bind again with the above > > line makes the usb_ether gadget and fastboot work again. Whereas with > > your series the unbind behaves identically but the bind command does not > > "fix" fastboot (tftp works fine in v3). > > =20 > >> Can you try and debug this ? =20 > >=20 > > The breakage is not part of the existing code base, it was introduced > > by the series. Maybe you can try with any other board with USB > > peripheral and see if the behavior is identical? > > =20 > >> Does 'fastboot usb 1' work with this series by any chance ? =20 > >=20 > > When fastboot works, starting it "blocks" the CLI. When I unbind the > > peripheral driver on USB 0, the fastboot command does not block any > > more and yet does not print anything, it just returns "immediately" > > without any log. > >=20 > > When I run 'fastboot usb 1' it acts like that as well, nothing happens, > > without error. It acts identically before and after this series. =20 >=20 > Please test v4 I will. Thanks, Miqu=C3=A8l