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 3AFB1EB64DD for ; Tue, 1 Aug 2023 23:07:49 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2B6AF8697D; Wed, 2 Aug 2023 01:07:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1690931268; bh=FxG5mmsCbSPGv5hZDAwH1GTlbaMhp0UXAlCNt7z6JWA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=lrA8B4ZCYoUmHx6yR5di8eKFBNN7M8Zhzs+cas+bCsNHjMhKn7N7p9c1eYztPe9vQ e0LBInUS0VacNduI0miFNrX4duCHSjXlHgC1dE5MCQ5XzLPy/0KEyslD2PZ8+4CtPe mnnkDAMKwtSI5Z8BOBbV+bliqANOhqly4qRZmL+ZQ/SjvDyVK5dBi81g96zvan2fVh dxGlg/A8rOsdsHZ/ZZvV6Q6MU9I7W9lQV4tByjWt+k8LTmg3i6jhsjWkIe+0zZA70L pZ2MI5/1YjN9T3EPyAAEiqZWnQTs/zlNnmRE8eCmYJO6t12NXo2FJBM0a8VSmqUWdz LQiZhdSJWxujw== Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id A20A58697D; Wed, 2 Aug 2023 01:07:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1690931267; bh=FxG5mmsCbSPGv5hZDAwH1GTlbaMhp0UXAlCNt7z6JWA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=C8QS2pahE4HDAOiQZEep7V7iP8KZRwBYz9tTFJAAlQuklWEnPEq52ZbqYUSyFjBpT k5SD5BzNVzRnupDCqFDKQ5c+GdeSolC6YADzuK1eyxMalP4CA1tkouA1nXNbqc2WeS iloiu6F4M6yGOGtf6Cv7IhwvVz28w9xilCuLgDvm9y/ldxuryJoiHopv4XMuSedr9p 8+6wWjoHNx2ffsLerrrtviB+6SBhPaHrQaFZUylF4h/ETfHPlcx45hox8AZsaCOt14 +06N6K6LaRHahIHTgtgX3AFYE+4K3GmiPpVHUm0VldEykLA9T5D5RnbPfOsk9Y1RmA nStTxFxFnT7Xw== Message-ID: <85b8d9a7-db07-429b-e880-677f575f05c7@denx.de> Date: Wed, 2 Aug 2023 01:07:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.1 Subject: Re: [PATCH v3 1/4] cmd: bind: Add unbind command with driver filter Content-Language: en-US To: Miquel Raynal Cc: u-boot@lists.denx.de, Kevin Hilman , Lukasz Majewski , Simon Glass 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> From: Marek Vasut In-Reply-To: <20230801205342.2fdbffc8@xps-13> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 8/1/23 20:53, Miquel Raynal wrote: > Hi Marek, > > marex@denx.de wrote on Mon, 31 Jul 2023 16:40:04 +0200: > >> On 7/31/23 16:25, Miquel Raynal wrote: >>> Hi Marek, >>> >>> marex@denx.de wrote on Mon, 31 Jul 2023 16:08:19 +0200: >>> >>>> On 7/31/23 15:58, Miquel Raynal wrote: >>>>> Hi Marek, >>>>> >>>>> marex@denx.de wrote on Mon, 31 Jul 2023 15:50:58 +0200: >>>>> >>>> On 7/31/23 15:36, Miquel Raynal wrote: >>>>>>> Hi Marek, >>>>>>> >>>>>>> marex@denx.de wrote on Mon, 31 Jul 2023 13:44:25 +0200: >>>>>>> >>>> On 7/31/23 11:31, Miquel Raynal wrote: >>>>>>>>> Hi Marek, >>>>>>>>> >>>>>>>>> marex@denx.de wrote on Sat, 29 Jul 2023 16:57:09 +0200: >>>>>>>>> >>>> Extend the driver core to perform lookup by both OF node and driver >>>>>>>>>> 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 gadget >>>>>>>>>> drivers bound to it. The unbind command has to select that specific >>>>>>>>>> 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. Notice >>>>>>>>>> the extra 'usb_ether' addition in the 'unbind' command at the 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 >>>>>>>>>> --- >>>>>>>>> >>>>>>>>> I am no longer getting wrong pointer dereferences, the SPL is working in >>>>>>>>> recovery mode, TFTP "File not found" errors are no longer a problem and >>>>>>>>> I did not experience any reset while tftp'ing regular files. >>>>>>>>> >>>>>>>>> One last remaining request on my side is the need for using fastboot as >>>>>>>>> well which does no longer work as-is: >>>>>>>>> >>> => fastboot usb 0 >>>>>>>>> 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 here? >>>>>>>> >>>>>>>> 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 '. >>>>>>> >>>>>>> Nice `dm tree` command, never used it before. >>>>>>> >>>>>>> Even when I unbind usb_ether I still get the same error: >>>>>>> >>> => unbind /ocp/usb@47400000/usb@47401000 >>>>>>> => fastboot usb 0 >>>>>>> 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 manually? >>>>>> >>>>>> Can you share the output of dm tree before/after unbind ? >>>>>> >>>>>> fastboot should auto-bind to the right thing. >>>>> >>>>> 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) >>>> >>>> [...] >>>> >>>>> watchdog 0 [ + ] omap3_wdt | |-- wdt@44e35000 >>>>> misc 0 [ + ] ti-musb-wrapper | |-- usb@47400000 >>>>> usb 0 [ + ] ti-musb-peripheral | | |-- usb@47401000 >>>>> ethernet 1 [ + ] usb_ether | | | `-- usb_ether >>>>> bootdev 3 [ ] eth_bootdev | | | `-- usb_ether.bootdev >>>>> usb 0 [ ] ti-musb-host | | `-- usb@47401800 >>>>> ethernet 0 [ + ] eth_cpsw | |-- ethernet@4a100000 >>>>> bootdev 2 [ ] eth_bootdev | | `-- ethernet@4a100000.bootdev >>>>> simple_bus 67 [ ] ti_sysc | |-- target-module@53100000 >>>>> simple_bus 68 [ ] ti_sysc | |-- target-module@53500000 >>>>> simple_bus 69 [ ] ti_sysc | `-- target-module@56000000 >>>>> clk 62 [ ] fixed_clock |-- clk_mcasp0_fixed >>>>> bootstd 0 [ ] bootstd_drv |-- bootstd >>>>> bootmeth 0 [ ] bootmeth_efi | |-- efi >>>>> bootmeth 1 [ ] bootmeth_extlinux | |-- extlinux >>>>> bootmeth 2 [ ] bootmeth_pxe | |-- pxe >>>>> bootmeth 3 [ ] vbe_simple | `-- vbe_simple >>>>> timer 0 [ + ] omap_timer `-- timer@0 >>>>> => unbind /ocp/usb@47400000/usb@47401000 >>>> >>>> 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 >>> >>> Does not work, unfortunately: >>> => unbind /ocp/usb@47400000/usb@47401000 usb_ether >>> Cannot find a device with path /ocp/usb@47400000/usb@47401000 >>> => unbind /ocp/usb@47400000/usb@47401000 >> >> 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 important) ? > > Yes it did. > >> Can you debug this ? Basically the problem that happens is that if you run: >> unbind /ocp/usb@47400000/usb@47401000 >> this unbind ti-musb-peripheral usb@47401000 instead of just unbinding >> usb_ether usb_ether > > True. > >> Maybe just try >> unbind usb_ether > > => unbind usb_ether > unbind - Unbind a device from a driver > > Usage: > unbind [] > unbind > unbind > >> or >> unbind usb_ether usb_ether > > => unbind usb_ether usb_ether > usb_ether is not a valid uclass > >> ti-musb-peripheral usb@47401000 has to stay in the dm tree output after the unbind. Or maybe try >> >> bind /ocp/usb@47400000/usb@47401000 ti-musb-peripheral > > Indeed when we perform the unbind, ti-musb-peripheral is removed. Yes, > binding it again like you advise makes it come back. > >> and then the fastboot thing > > 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@47401800 > usb 0 [ ] ti-musb-peripheral | | `-- usb@47401000 > > It still fails: > > => fastboot usb 0 > couldn't find an available UDC > g_dnl_register: failed!, error: -19 > exit not allowed from main input shell. > > Without this series, this works: > => unbind /ocp/usb@47400000/usb@47401000 > => bind /ocp/usb@47400000/usb@47401000 ti-musb-peripheral > => fastboot usb 0 OK, so fastboot did not work even without this series without obscure workarounds ? Can you try and debug this ? Does 'fastboot usb 1' work with this series by any chance ?