mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master] net: workaround NICs and MDIO busses sharing same OF node
Date: Thu,  2 May 2024 09:03:28 +0200	[thread overview]
Message-ID: <20240502070328.2218748-1-a.fatoum@pengutronix.de> (raw)

v2024.04.0 broke Ethernet on the Skov IMX6 board:

  ERROR: KSZ8873 MDIO mdio1-dev00: can't find ethernet master device

The board has an Ethernet switch controlled via a bitbanged
MDIO bus and the MDIO bus of the Ethernet device is unused.

The FEC node has no mdio subnode, just a fixed-link.

Starting with commit ac855ffe5730 ("net: phy: fix miibus parent
device of_node not matching phy node"), MDIO busses will get assigned
the device tree node of their parent if none was configured.
This means we have two devices competing for the same device tree node:

  barebox@Skov IMX6:/ devinfo 2188000.ethernet@2188000.of
  [...]
  Device node: /soc/bus@2100000/ethernet@2188000 (populated by miibus0)

This has the effect that calling of_device_ensure_probed on the device
tree fails with -EPROBE_DEFER because miibus0 has no driver bound and
the network device itself is ignored.

We probably want to rethink allowing multiple devices to share the same
device tree node, especially for network drivers. But as long this is
the case, fix the regression by always walking the list of registered
device tree nodes.

Fixes: ac855ffe5730 ("net: phy: fix miibus parent device of_node not matching phy node")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 net/eth.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/net/eth.c b/net/eth.c
index 28961e868b7a..98567d8d3fc2 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -528,11 +528,12 @@ void led_trigger_network(enum led_trigger trigger)
 struct eth_device *of_find_eth_device_by_node(struct device_node *np)
 {
 	struct eth_device *edev;
-	int ret;
 
-	ret = of_device_ensure_probed(np);
-	if (ret)
-		return NULL;
+	/* There may multiple devices with the same device_node, e.g.
+	 * MII bus and Ethernet controller. Thus ignore errors and
+	 * walk the full list of registered network devices below
+	 */
+	(void)of_device_ensure_probed(np);
 
 	list_for_each_entry(edev, &netdev_list, list)
 		if (edev->parent->of_node == np)
-- 
2.39.2




             reply	other threads:[~2024-05-02  7:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-02  7:03 Ahmad Fatoum [this message]
2024-05-03  6:57 ` Sascha Hauer

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=20240502070328.2218748-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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