Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp500779pxb; Tue, 19 Oct 2021 07:16:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFp6hG29uyjkbEMIxNhzHyZTYEHTyqEh937eGI1BQBlm15fogrwJnuZOJE7MXfa0ELOWa4 X-Received: by 2002:a65:44c4:: with SMTP id g4mr29590997pgs.254.1634652968446; Tue, 19 Oct 2021 07:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634652968; cv=none; d=google.com; s=arc-20160816; b=jPRXXfh6A3+pivr/FkHsus2mvgJ6oX+oOK7jwurZ2tynVrqIPj+wMOo1I3FYpXQ2tu fYgpzUGQtv9ydtqyCb/UzW6FyWexJRBq2diaigk5+0iDdUs6R1uiBPgh9A2XqF/gLipD XhJdg4l01iAO9544Z/fNEvDe8ID2feJxGtJsQY11UMyvaeKXIn3xmjaGa6j+R5gLfiQV GDkX5/0z/B/RhYfjqlVDvBZm9JCEu73cPfcxQifmhYPsuGytwU1bWiwa/hRWejUyyLrh /z1VGsTSzcS849iLuNf7FL0WZRi2fqMUkKL/OmtNAQIG4r6zikyyfDiHM/NLBBZ1Pa9V 54dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=dxAB3/KI9gLEOMDEfLD6UlFEaKIHK37cTRFK56RYQ1s=; b=DtC1MKj6RnMoXts6tEVQbckCCSgddVqDoYxLs+9xLvP2OQTTBHfdtGYWP5qcTpmMYc zxamSxY8a1qPW5rdXkQS9FdgYC5ALCu92wvhwIpE7wpWuM2fVdwiTFNUMvNk2jraQ7ji xvr9K2BBSnJjj+FXIwhHQ9cv7GTSm084QJm0PAiFM9eeDvPctVzBRm2HhwYVoT3KhRwo ayWQ7bkYFeOZfPTsncay+PG4Jeoep3MWtmA7P6NACpn2u3RcF2KeZjBaLn+xX0y12HZ5 IFyMXjK4+K6Lkx6BLAYwTQoZUQ8PyIEunCVvxdIQKZutd+vJhcyI/LK6kcMFYlgNaF1j epIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=lkgtla6Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o13si4090852pji.71.2021.10.19.07.15.56; Tue, 19 Oct 2021 07:16:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=lkgtla6Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231442AbhJSOPA (ORCPT + 99 others); Tue, 19 Oct 2021 10:15:00 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:46686 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229584AbhJSOPA (ORCPT ); Tue, 19 Oct 2021 10:15:00 -0400 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=dxAB3/KI9gLEOMDEfLD6UlFEaKIHK37cTRFK56RYQ1s=; b=lkgtla6QQliqlIOSh91D1xnw/e Q17Um7/THybOKNk6gCcZq8cL/vuavdOLGJ33EL6iiZiCdokXGy0x8oBFIWKNrVydBJ8iKcHRK6NtF YkS6LUjxyCQrpYLmLI5/HClHPWWphnnCmRlHJ9I8EmleUit1CcafKR9Rg8sRRtZfsTJY=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1mcpr6-00B5FF-Sl; Tue, 19 Oct 2021 16:12:40 +0200 Date: Tue, 19 Oct 2021 16:12:40 +0200 From: Andrew Lunn To: Matthias Schiffer Cc: Joakim Zhang , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: fec: defer probe if PHY on external MDIO bus is not available Message-ID: References: <20211014113043.3518-1-matthias.schiffer@ew.tq-group.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211014113043.3518-1-matthias.schiffer@ew.tq-group.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 14, 2021 at 01:30:43PM +0200, Matthias Schiffer wrote: > On some SoCs like i.MX6UL it is common to use the same MDIO bus for PHYs > on both Ethernet controllers. Currently device trees for such setups > have to make assumptions regarding the probe order of the controllers: > > For example in imx6ul-14x14-evk.dtsi, the MDIO bus of fec2 is used for > the PHYs of both fec1 and fec2. The reason is that fec2 has a lower > address than fec1 and is thus loaded first, so the bus is already > available when fec1 is probed. > > Besides being confusing, this limitation also makes it impossible to use > the same device tree for variants of the i.MX6UL with one Ethernet > controller (which have to use the MDIO of fec1, as fec2 does not exist) > and variants with two controllers (which have to use fec2 because of the > load order). > > To fix this, defer the probe of the Ethernet controller when the PHY is > not on our own MDIO bus and not available. > > Signed-off-by: Matthias Schiffer > --- > drivers/net/ethernet/freescale/fec_main.c | 23 ++++++++++++++++++++++- > 1 file changed, 22 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c > index 47a6fc702ac7..dc070dd216e8 100644 > --- a/drivers/net/ethernet/freescale/fec_main.c > +++ b/drivers/net/ethernet/freescale/fec_main.c > @@ -3820,7 +3820,28 @@ fec_probe(struct platform_device *pdev) > goto failed_stop_mode; > > phy_node = of_parse_phandle(np, "phy-handle", 0); > - if (!phy_node && of_phy_is_fixed_link(np)) { > + if (phy_node) { > + struct device_node *mdio_parent = > + of_get_next_parent(of_get_parent(phy_node)); > + > + ret = 0; > + > + /* Skip PHY availability check for our own MDIO bus to avoid > + * cyclic dependency > + */ > + if (mdio_parent != np) { > + struct phy_device *phy = of_phy_find_device(phy_node); > + > + if (phy) > + put_device(&phy->mdio.dev); > + else > + ret = -EPROBE_DEFER; > + } I've not looked at the details yet, just back from vacation. But this seems wrong. I would of expected phylib to of returned -EPRODE_DEFER at some point, when asked for a PHY which does not exist yet. All the driver should need to do is make sure it returns the -EPRODE_DEFER. Andrew