Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1506753lqm; Thu, 2 May 2024 18:25:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVF+qlyyBy53p8KD6HEAQE3JCIPc+ekZ+UqGg7jUurlLYjTd+q0R0PfNmv6p0P84aKajXCFPM9ug10yJUweIfDGcDHhHC8OaSHBXBhFWQ== X-Google-Smtp-Source: AGHT+IEKmXb9DHiMVMObXHAH4SmJp5sFcLp044xmvVKdZZdV4ojcOC9N0Sap5wTseozRzd+ys4AL X-Received: by 2002:a05:6a21:3287:b0:1ad:1c9d:f682 with SMTP id yt7-20020a056a21328700b001ad1c9df682mr1797975pzb.35.1714699551673; Thu, 02 May 2024 18:25:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714699551; cv=pass; d=google.com; s=arc-20160816; b=YXlxVLC+wFTJBSE+WQycoyR0WoO9Zjoc/7/UZEsUHc7lYLlrepZ+UzNnX4sB1yi8os zcHwM89Gq4ofMeJxT+oZMtPam9gudBy0W4J1vIsbpSMYiWO5TWy9eRlK/K6KyT3LMQhy E62JUleI2Mup6csEZeUXa0tEw1IY4mKqiIK4QwRDF4S/lDD3BtDJHU69mf+/w5UOtEyf KcWKuP4YCV8JyEIM+P2a+vdV8WvZqdBMp1pP6t9nkKFWkjW4lfQwexF0IKAUVJA7+42/ KmannGRjQNjviKlKMNW5fNmwKNirIObSdbKQSXWGBXVvXn7jQufwqVMWBghf9JcrDXxB IzpQ== 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=rPaJqqgEDySEy7m0HaNo8dsnzSm/N9I0/G6a8VXE0NA=; fh=WR4SWsVH8bYS+yJDjYjUQU5fKT5vk+RIUPyJfEIwL7k=; b=HnU4N2/xLBj2fwmCx+DQBmJyXZ3sVtOc+AQbAwmVUwchUWK5zzybb23t2a/xgsy1F1 arvBP9nywwCldYGN/vW4zek/syV2oo3kglk9zUSJBp5lQT7XPhL3NxcIYf5Y3nLmyjlX J7przZNMoQjjRsUaVQfDMi5AIdCee6cvVndBjQWbUdDxPJYujOVfIne3WODTc3rtQaWO oSKjIWdsDKdri57rR2kkwYW6gJqU3L0NF3PvN01oNCMRjrbe9sSrc6rdaGimgiJEyIkZ VnyMms4LQpukeKj1UYwfZnpZDq2qcrpuT90OCNLfyxOQwtM7DFA7N+3fV1spSPq7XHC7 KTfQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=G3iSQ0lF; 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-167141-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167141-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id n4-20020a170902dc8400b001eb5c405471si1923991pld.455.2024.05.02.18.25.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 18:25:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167141-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=G3iSQ0lF; 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-167141-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167141-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D910CB21ADD for ; Fri, 3 May 2024 01:25:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA94FE57E; Fri, 3 May 2024 01:25:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="G3iSQ0lF" 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 C31D88C05; Fri, 3 May 2024 01:25:33 +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=1714699536; cv=none; b=oGPzLPDTZdlBdp6xJsEBJhF4+3lCrSrSCTPDevqS4yqzPSGXlWKHaXDVrFtK5UBh+iK06Gxi9GOHpdoy5aOsPGEoQfJu2nLhpzVG0GlFk3Skg/7JS8aztkFDVAIjvTzACybXurKBBwSZaUlvOgiHay5/SJ5YTFWuOOp0/JrhRis= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714699536; c=relaxed/simple; bh=S+1vg85RtNFRN/JDYIDaIn7QFx/jLQ9h75TpWJA8Dmo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=E/rwt5hfObvWkMZ+K5/Lk21RerIAN28VLy3QYEwAVBZN97o4UJU9JOPlTbjO57pNsOztEg5b8XeqQyvgL3VWpL77VFX9Je4/Adx1qbaKbQoG5MZVnuPlP4e38SKAtPxBezjvzguonQpai5ZHpspIslvpqnI1qt8yXgBH2ZbHdlE= 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=G3iSQ0lF; 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=rPaJqqgEDySEy7m0HaNo8dsnzSm/N9I0/G6a8VXE0NA=; b=G3iSQ0lFTzjf7q24aBd4DutcCh T7kJxoiU3WKIB80JHJI3irt9WQKmxOhjdzoDfpb1kplsX6x8CRVvBdYVCm7rKGNsWTztVazbf9QXv nmKnOScH08h+7b7DiICyFQ1R01l/AP5sNmk3VxIrMRkUptPWYJUWcnACbcQErotrnPxM=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1s2hfr-00EXRq-Rh; Fri, 03 May 2024 03:25:19 +0200 Date: Fri, 3 May 2024 03:25:19 +0200 From: Andrew Lunn To: Serge Semin Cc: Andrew Halaney , "Russell King (Oracle)" , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, netdev@vger.kernel.org, alexandre.torgue@foss.st.com, joabreu@synopsys.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, hkallweit1@gmail.com Subject: Re: racing ndo_open()/phylink*connect() with phy_probe() Message-ID: <25d1164e-0ac2-4311-ad27-aa536dca3882@lunn.ch> References: <7723d4l2kqgrez3yfauvp2ueu6awbizkrq4otqpsqpytzp45q2@rju2nxmqu4ew> 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: <7723d4l2kqgrez3yfauvp2ueu6awbizkrq4otqpsqpytzp45q2@rju2nxmqu4ew> > AFAICS the problem is in the race between the end0 and end1 device > probes. Right? > If so then can't the order be fixed by adding the links between the > OF-devices? As it's already done for various phandle-based references > like "clocks", "gpios", "phys", etc? It gets tricky because an MDIO bus master device is often a sub device of an Ethernet MAC driver. Typically how it works is that a MAC driver probes. Part way through the probe it creates an MDIO bus driver, which enumerates the MDIO bus and creates the PHYs. Later in the MAC driver probe, or maybe when the MAC driver is opened, it follows the phy-handle to a PHY on its own MDIO bus. If you were to say it cannot probe the MAC driver until the MDIO bus driver is created and the PHYs created, you never get anywhere, because it is the act of probing the MAC driver which creates the PHYs which fulfils the phandle. You would need to differentiate between a phandle pointing deeper into the same branch of a DT tree, or pointing to a different branch of a DT tree. If it is deeper within the same branch, you need to probe in order to make progress. If it points to a different branch you need to defer until that sub-branch has successfully probed. And if you get two branches which are mutually dependent on each other, probe and hope EPROBE_DEFER solves it. Andrew