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 75E0CC05027 for ; Mon, 23 Jan 2023 11:26:18 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6187685726; Mon, 23 Jan 2023 12:26:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (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=1674473176; bh=jJq/dAJFiYyin7CglFZ61kcyNs5DR5706np8gHtwPBM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LXEF96Zmqgt0XA66Blctvfdya4gmmKdSFCFUyxRMz6p036lKgmeHY1OHu73ne48nH CEvuVZy3Kghab5PJ661L9X2o1EZ1Ol2lubI2cHkl/aCJ7ooTGauVoglDi5nKwcnlq2 RbPmf+rGxWItHUW1ChK94d8SQ3q8q6pps5z7rzeqMXkgvryd6WAB8okM6gvdh1Wtvb b7crNOvuPKElOSd3GiC+zT13xSKSqlOhLFSNL9Rm0wmKtXJ4kKsFmWk6UumHOWkJXd inSUKkxtxG1oKjZyw6CPijua4MoYSS3IwqwDlK2in4FNZiVfb12DmufX7jo4k5dw1h Uoj3pdGgW8R6A== Received: from [192.168.0.6] (unknown [62.91.23.180]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: lusus@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id C9B0B8570D; Mon, 23 Jan 2023 12:26:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1674473175; bh=jJq/dAJFiYyin7CglFZ61kcyNs5DR5706np8gHtwPBM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Gq57T1oP4Zxp6PfZ6PnX7JTHErzIdjRmKjyuOyYTPWYsSJl1Q4QBNo1Jfzam5jEXX cytxnnwpmqXilw9uqXZeRxOo1IIUVN4anFQazEfoZc2rxWZhAecDAjdLCNzMjfoNkV UFvjXF+1Ii81liPIftCAOah7c7Nsn0e2dmTCNQsahbPezgG9+CfYhhxkeE28JMW6Yr qw2lczIpQ/CCG7V4/V4Mto8Ptbdyrvx8MHEeXa/ZJPuw1auCYcos68NBeYnoWXuZ3Q HyYurgnRbeL769YkX+Cm4Eaegh5RG1zOtg5k9PJ2zbRP9eFYa7Z5UvTp4mF0ea/wHu IySAOjvPesNLg== Message-ID: Date: Mon, 23 Jan 2023 12:26:14 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH v2] usb: gadget: ether: split start/stop from init/halt Content-Language: en-US To: Marek Vasut , u-boot@lists.denx.de Cc: Lukasz Majewski , Ramon Fried References: <20230120171518.896027-1-lusus@denx.de> From: Niel Fourie In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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.6 at phobos.denx.de X-Virus-Status: Clean Hi Marek On 20/01/2023 19:42, Marek Vasut wrote: > On 1/20/23 18:15, Niel Fourie wrote: > > [...] > > Same question as in V1 below. > >> +static int _usb_eth_start(struct ether_priv *priv) >> +{ >> +    unsigned long timeout = USB_CONNECT_TIMEOUT; >> +    struct eth_dev *dev = &priv->ethdev; >> +    unsigned long ts; >> +    if (!dev->gadget) >> +        return -1; >> + >> +    dev->network_started = 0; > > > Will this work on systems which already have netconsole active ? I think > this would break the netconsole connection, since the network would be > reinitialized, won't it ? Good question, sorry for being unclear in my previous email. The upper layers appear to do a good job of taking the connection down and then bringing it up again when the network_started calls remain where they are. Here is an example run (copied from the serial console with console multiplexing enabled), where the last two dhcp calls were happily issued over the Netconsole: u-boot=> bind /soc@0/usb@32f10100/usb@38100000 dwc3-generic-peripheral u-boot=> bind /soc@0/usb@32f10100/usb@38100000 usb_ether u-boot=> setenv autoload no u-boot=> setenv ethact eth2 u-boot=> setenv nc 'setenv stdout serial,nc;setenv stdin serial,nc' u-boot=> setenv ncip 10.42.0.1 u-boot=> dhcp using dwc3-gadget, OUT ep2out IN ep1in STATUS ep3in MAC de:ad:be:ef:00:01 HOST MAC de:ad:be:ef:00:00 high speed config #1: 2 mA, Ethernet Gadget, using CDC Ethernet ep1in is already disabled ep2out is already disabled USB network up! BOOTP broadcast 1 DHCP client bound to address 10.42.0.65 (193 ms) u-boot=> run nc u-boot=> high speed config #1: 2 mA, Ethernet Gadget, using CDC Ethernet ep1in is already disabled ep2out is already disabled USB network up! u-boot=> dhcp BOOTP broadcast 1 DHCP client bound to address 10.42.0.65 (153 ms) u-boot=> high speed config #1: 2 mA, Ethernet Gadget, using CDC Ethernet ep1in is already disabled ep2out is already disabled USB network up! u-boot=> dhcp BOOTP broadcast 1 DHCP client bound to address 10.42.0.65 (144 ms) u-boot=> Stuck? Emptying request_list... head=bdf617c8, next=bdf64c88; high speed config #1: 2 mA, Ethernet Gadget, using CDC Ethernet ep1in is already disabled ep2out is already disabled USB network up! u-boot=> The "Stuck? Emptying request_list... head=bdf617c8, next=bdf64c88;" message comes from the dwc3 workaround I mentioned in the previous email. I will share it later as RFC, because I am a bit stumped at how the list_head ends up not being in the list when Netconsole is enabled. > I would expect this assignment to be in _init and _stop , not in _start > callback. I tried moving the dev->network_started as you requested, and it caused the driver to hang, on (say) the second "dhcp" command, even without Netconsole enabled. Unfortunately GDB was not particularly helpful in getting a backtrace for identifying exactly where/why. > But I wonder whether the current ethernet uclass interface running code > does not make the entire network_started mechanism obsolete. See the > patch which you referenced previously in related patch: > > fa795f45254 ("net: eth-uclass: avoid running start() twice without stop()") From what I could gather from my testing (shown above) it appears to working as expected, but I admit I am not sure how/why. The dev->network_started variable appears to be specific to the ether.c file, and does not directly interact with the other layers, like eth-uclass. I wish I could give you a better explanation... Best regards, Niel Fourie -- DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-21 Fax: +49-8142-66989-80 Email: lusus@denx.de