From: Andrew Lunn <andrew@lunn.ch>
To: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Cc: Joakim Zhang <qiangqing.zhang@nxp.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
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
Date: Tue, 19 Oct 2021 16:12:40 +0200 [thread overview]
Message-ID: <YW7SWKiUy8LfvSkl@lunn.ch> (raw)
In-Reply-To: <20211014113043.3518-1-matthias.schiffer@ew.tq-group.com>
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 <matthias.schiffer@ew.tq-group.com>
> ---
> 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
next prev parent reply other threads:[~2021-10-19 14:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-14 11:30 [PATCH] net: fec: defer probe if PHY on external MDIO bus is not available Matthias Schiffer
2021-10-18 10:20 ` Joakim Zhang
2021-10-18 10:32 ` Matthias Schiffer
2021-10-19 14:12 ` Andrew Lunn [this message]
2021-10-20 12:03 ` Matthias Schiffer
2021-10-20 18:50 ` Andrew Lunn
2021-10-21 7:08 ` (EXT) " Matthias Schiffer
2021-10-21 12:50 ` Andrew Lunn
2021-10-22 7:57 ` Matthias Schiffer
2021-10-22 12:56 ` Andrew Lunn
2021-10-26 11:54 ` Matthias Schiffer
2021-11-03 11:59 ` Matthias Schiffer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YW7SWKiUy8LfvSkl@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthias.schiffer@ew.tq-group.com \
--cc=netdev@vger.kernel.org \
--cc=qiangqing.zhang@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox