mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] net: workaround NICs and MDIO busses sharing same OF node
@ 2024-05-02  7:03 Ahmad Fatoum
  2024-05-03  6:57 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-05-02  7:03 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH master] net: workaround NICs and MDIO busses sharing same OF node
  2024-05-02  7:03 [PATCH master] net: workaround NICs and MDIO busses sharing same OF node Ahmad Fatoum
@ 2024-05-03  6:57 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-05-03  6:57 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Thu, 02 May 2024 09:03:28 +0200, Ahmad Fatoum wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] net: workaround NICs and MDIO busses sharing same OF node
      https://git.pengutronix.de/cgit/barebox/commit/?id=4d0598d894fd (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-03  6:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-02  7:03 [PATCH master] net: workaround NICs and MDIO busses sharing same OF node Ahmad Fatoum
2024-05-03  6:57 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox