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 36AF0C001DE for ; Fri, 4 Aug 2023 17:18:27 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4F9FA86927; Fri, 4 Aug 2023 19:18:25 +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=1691169505; bh=B6zmyJlSTuqdzDnkMGdVKtAf3IUzlX1YSwO1vtT2KQI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=bMaS6ro0Rj36q6SE97eW9dYZtgNAiB5jmtpJEm04Y7kh7RtghlATp2dC9W9q+nGr6 ZXPCo3OPCWktlTpwxSp3JCh6nd2kjx+4lOMWKsZE55hlSYFGuPNWw7q1wcywB1230m 00N6cM/RTAIq2tNhQcV5K8iyr15mDNrQFueRIxk0JVgZEq4Mc31wPeOa7GhMywldc0 0wzVy2MkmiJenZ4MoO7vY8rtBZA+yjnVxTvKXA7JYH24Au5bSRbgL1XOYDqLGXPfIw kYNmMhTzMtZhaOEaXDvuThAHig2cALE4j22wCOG3Z3XGaDfz5nrym65grrzLbJfjk0 sKcOYuW7mGKyA== 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 140608691E; Fri, 4 Aug 2023 19:18:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1691169504; bh=B6zmyJlSTuqdzDnkMGdVKtAf3IUzlX1YSwO1vtT2KQI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=eUTtryBJbAd8s9p4NT9f4lNEwYfxXlZ2r0V67TxQ6+hBpYE3nXDk93PBEMXNg7MPa 3buUknWI9O3z8F1Y9xvg+UuijGPMfu7Uk+L2xd6yr+LnrbFkFuSZu4rb8jCUIcOqRm eWZAo85kQD31MCTlV0wrivCwT1jCAqZJUjaTQIB15Vewyqd5xqKUAwSlX3zCMOGsj4 rgfxMf114sBbuk6pxmjzLHnJbDIPSxtCA+bSJfVcLUdPbnSoxDyinFuoOGcGs8r9gj wUQ5R3VBGR0QZWydzYeeL/DCR6qacMmbJ2s0/6etGtJrnbfzEDGp6XhLRJiAtVNSIf 5QhyGkBF5c0Cg== Message-ID: <808fc98c-73e9-cbed-c593-ae4256d5dbcc@denx.de> Date: Fri, 4 Aug 2023 19:18:23 +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 v4 1/4] cmd: bind: Add unbind command with driver filter Content-Language: en-US To: Miquel Raynal , Tom Rini Cc: u-boot@lists.denx.de, Kevin Hilman , Lukasz Majewski , Simon Glass 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> <20230804161515.GR3630934@bill-the-cat> <20230804190146.2595e241@xps-13> From: Marek Vasut In-Reply-To: <20230804190146.2595e241@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/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.