[PATCH master] net: workaround NICs and MDIO busses sharing same OF node

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx
  [...]
  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@xxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux