[openwrt/openwrt] realtek: early ethernet probe in dsa setup

LEDE Commits lede-commits at lists.infradead.org
Sun Sep 7 02:38:04 PDT 2025


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/3fae46d5cc723ae680d0ba721368a3677b6ae799

commit 3fae46d5cc723ae680d0ba721368a3677b6ae799
Author: Markus Stockhausen <markus.stockhausen at gmx.de>
AuthorDate: Wed Sep 3 04:02:51 2025 -0400

    realtek: early ethernet probe in dsa setup
    
    The ethernet and mdio code will be splitted. The dsa driver depends
    on proper loading of both, before switch setup can start. Sadly there
    are severe cleanup issues in the probe() function if one of the
    required devices is not available.
    
    As a temporary workaround provide a dedicated check function that
    verifies if the ethernet platform device driver is loaded and can
    be used.
    
    Signed-off-by: Markus Stockhausen <markus.stockhausen at gmx.de>
    Link: https://github.com/openwrt/openwrt/pull/19942
    Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 .../files-6.12/drivers/net/dsa/rtl83xx/common.c    | 43 ++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
index eef52e4ac2..80b36ec5a8 100644
--- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
+++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
@@ -1455,6 +1455,45 @@ static int rtl83xx_fib_event(struct notifier_block *this, unsigned long event, v
 	return NOTIFY_DONE;
 }
 
+/*
+ * TODO: This check is usually built into the DSA initialization functions. After carving
+ * out the mdio driver from the ethernet driver, there are two drivers that must be loaded
+ * before the DSA setup can start. This driver has severe issues with handling of deferred
+ * probing. For now provide this function for early dependency checks.
+ */
+static int rtldsa_ethernet_loaded(struct platform_device *pdev)
+{
+	struct device_node *dn = pdev->dev.of_node;
+	struct device_node *ports, *port;
+	int ret = -EPROBE_DEFER;
+
+	ports = of_get_child_by_name(dn, "ports");
+	if (!ports)
+		return -ENODEV;
+
+	for_each_child_of_node(ports, port) {
+		struct device_node *eth_np;
+		struct platform_device *eth_pdev;
+
+		eth_np = of_parse_phandle(port, "ethernet", 0);
+		if (!eth_np)
+			continue;
+
+		eth_pdev = of_find_device_by_node(eth_np);
+		of_node_put(eth_np);
+
+		if (!eth_pdev)
+			continue;
+
+		if (eth_pdev->dev.driver)
+			ret = 0;
+	}
+
+	of_node_put(ports);
+
+	return ret;	
+}
+
 static int __init rtl83xx_sw_probe(struct platform_device *pdev)
 {
 	int i, err = 0;
@@ -1467,6 +1506,10 @@ static int __init rtl83xx_sw_probe(struct platform_device *pdev)
 		dev_err(dev, "No DT found\n");
 		return -EINVAL;
 	}
+	
+	err = rtldsa_ethernet_loaded(pdev);
+	if (err)
+		return err;
 
 	/* Initialize access to RTL switch tables */
 	rtl_table_init();




More information about the lede-commits mailing list