Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp888145lqs; Fri, 14 Jun 2024 08:25:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXEWhRRb5M4SP/4/i+yWNu4x8hDfU8ltiwlTHhDo2HFXXxkEMGX33CAeFbpyGYii+qHNFDzroGoa4g2c4OJ7k6Nm2IU3/2hi/2TpS76JA== X-Google-Smtp-Source: AGHT+IFrNOhF+L1sHeqT2aGVhFyDIkqJpr8LAtmkHGaJI77D0JCDomVEqGZjhj/W+vdBaV8j2aR0 X-Received: by 2002:a05:6a20:7344:b0:1b7:bdb3:7bc6 with SMTP id adf61e73a8af0-1bae802b526mr3178020637.45.1718378725896; Fri, 14 Jun 2024 08:25:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718378725; cv=pass; d=google.com; s=arc-20160816; b=MbONqrbBoc/SgHnEfh19UGZFttoI07Uaydhp47Zj3QnBmAH4TWBI/8HXWBV6XQ1DqV attl2Q1Vp9te0YxCSHyA6HJDPuqn5iqsI0dgEeqBKGGHGdOIolcL1ppqvj64dw1guWEz ok88AwIxhavfqhnPoTVPGoS4RXjlE76Vybg7gLBXxJramPAWUXOtJJJnzxNjokUaT2ur OcOJcUlt89N6uFQVpjbDGqCRK/QH8BET4/+rKVKfgGFkrekHN1hCEqtzKxacC+bNi8FP hNV81awX5H2HCoWG5nMzX+rplsXs28pCCUjMG5BG5UQUs7yBUckDIW5FQCFApNWeL6Fo OMTw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=bfVN5YN8JhVjpssbPI26uslRFd4p7nnZEhkAMORv9XM=; fh=W1R7QLwRf1oj7G7T9e1v6uvRctF22WHW4TCMEZnmY+Y=; b=shfWxLZpDUcukw5Hy9YH8Pak+woW6uJFyK6kKmYMeJ2yyza43/dN4rMXgGb4TB4OXR Ok88fUZXPO3MS+yACc43QTtC/nyr40ZeBt7rXNKW7oq1ZvbrjMYpPFxIswr1Xn56OBYm 3MevofhOvQ3spqhvyEosj4qerkBY0SEYOAG2wmFXLHo95YWphOQ4S99DOI/EjZpuiY6D YbinvzX/N5XChQWvwS6jxQnWcRqDkjVtxCzC2cuIEdPMA5uiFNXPQu4cVTFXxYgbk+Om gUtOQFygnYE4hKQYwWssR2gY/qQKhVwxo3u14yBBxP4tOukyLtxn0c7KPonfQyfm8oWB u4Ww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=rJSYDq3n; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-215126-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215126-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c4c461fa22si3766655a91.68.2024.06.14.08.25.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 08:25:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215126-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=rJSYDq3n; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-215126-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215126-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D989228B0EB for ; Fri, 14 Jun 2024 15:15:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E6D1319CD0A; Fri, 14 Jun 2024 15:11:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="rJSYDq3n" Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4623919AA6E; Fri, 14 Jun 2024 15:11:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718377900; cv=none; b=qpTEASackckHNaD9xUMs++/BPslxaQ9IWlPo+ra2H7N4gOd7fPlWY52A44JYc/Oyyfb/GjEVwmr0KwPv84Hb4HynkGL0uJdMEGkbO6tSLm2id2gd4MJ7qBph8KIQ5ty+D9RCIAa9jnOkHpzD6cvNh4x/df+Ps/ODd3SFGUYb8Jc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718377900; c=relaxed/simple; bh=/3Mg5rIwDCahxGgJ6iiybRmVjRLsews/D+g4t1liyx0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gLFw2AhO6fQqgJ/Yw/XovAnulKiYlx3vtjv+WH8RK5abA+pn7IvS1JL50auM+9ZULqtMB/nKxJlO5/wCYRMhURl9Iyy5y2MRBx6HkH3xVFo1qwDkOCG6Moo85NI3F1wy4RukSudQupWQYpHvdN0z9R6EQpjhUKqqBP/kcem50Lk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=rJSYDq3n; arc=none smtp.client-ip=156.67.10.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=bfVN5YN8JhVjpssbPI26uslRFd4p7nnZEhkAMORv9XM=; b=rJSYDq3nwAThqM8pk0ZJ+N9e74 TPoy0AM3t84gM/r3tHQE1vUj/c1wpZe8mZTmb35nvVPCAumadBWluGk5SelJDcpQOKLKT3TDA/QoI 05lnooBitw/KIhJNOt3chdZr095Qq707t7gsmpyQ7TJgSap1S1HzoZgcPKU+7OC/lgiY=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1sI8Cv-0004TC-Hl; Fri, 14 Jun 2024 16:47:13 +0200 Date: Fri, 14 Jun 2024 16:47:13 +0200 From: Andrew Lunn To: Paul Geurts Cc: wei.fang@nxp.com, shenwei.wang@nxp.com, xiaoning.wang@nxp.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, imx@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] fec_main: Register net device before initializing the MDIO bus Message-ID: <222fed4c-1613-40ec-b0a2-35b181fac795@lunn.ch> References: <51faeed2-6a6b-439b-80e6-8cf2b5ce401a@lunn.ch> <20240614084050.1205641-1-paul.geurts@prodrive-technologies.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240614084050.1205641-1-paul.geurts@prodrive-technologies.com> On Fri, Jun 14, 2024 at 10:40:50AM +0200, Paul Geurts wrote: > > On Thu, Jun 13, 2024 at 04:41:11PM +0200, Paul Geurts wrote: > > > Registration of the FEC MDIO bus triggers a probe of all devices > > > connected to that bus. DSA based Ethernet switch devices connect to the > > > uplink Ethernet port during probe. When a DSA based, MDIO controlled > > > Ethernet switch is connected to FEC, it cannot connect the uplink port, > > > as the FEC MDIO port is registered before the net device is being > > > registered. This causes an unnecessary defer of the Ethernet switch > > > driver probe. > > > > > > Register the net device before initializing and registering the MDIO > > > bus. > > > > The problem with this is, as soon as you call register_netdev(), the > > device is alive and sending packets. It can be sending packets even > > before register_netdev() returns, e.g. in the case of NFS root. So > > fec_enet_open() gets called, and tried to find its PHY. But the MDIO > > bus is not registered yet.... > > Valid argument there. I was trying to make the initialization more efficient, > but you are correct. Any changes to make this more efficient probably needs to be generic, and not in a specific Ethernet driver. One idea might be, when parsing the DT node for the MDIO bus, look to see if the device on the bus has a compatible which indicates it is not a PHY. If so, try to make the driver core put the device straight into deferred state, without even trying the first probe. Also, look at driver core devlink stuff. It tries to keep track of resource dependencies, and only probe devices when their resources are available. It does not seem to understand DSA too well, and it might be made better. But this is complex, we have dependency loops in network drivers, which causes devlink issues. Andrew