Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Arun Iyengar via B4 Relay
Sat, 28 Nov 2026 17:37
[PATCH net-next v5 6/6] net: stmmac: dwmac-sun8i: Register the MDIO mux in the MDIO setup
Author: Arun Iyengar via B4 Relay
Date: Sat, 28 Nov 2026 17:37
Date: Sat, 28 Nov 2026 17:37
111 lines
14032 bytes
14032 bytes
From: Arun Iyengar <aiyengar1990@gmail.com>
Both PHYs sit behind the mux, but the mux is registered only after
stmmac_pltfr_probe() has registered the netdev, so an early open does
not find the PHY. On remove, the mux goes away before
unregister_netdev(), and unbinding with the link up oopses in
phy_stop().
Register and unregister the mux through the mdio_init() and mdio_exit()
hooks added by "net: stmmac: Add MDIO init and exit platform hooks".
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Tested-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 41 ++++++-----------------
1 file changed, 10 insertions(+), 31 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 0ae0888467bb..09f07546f08c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -18,7 +18,6 @@
#include <linux/of_platform.h>
#include <linux/phy.h>
#include <linux/platform_device.h>
-#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>
#include <linux/regmap.h>
#include <linux/stmmac.h>
@@ -961,6 +960,13 @@ static int sun8i_dwmac_register_mdio_mux(struct stmmac_priv *priv)
return ret;
}
+static void sun8i_dwmac_unregister_mdio_mux(struct stmmac_priv *priv)
+{
+ struct sunxi_priv_data *gmac = priv->plat->bsp_priv;
+
+ mdio_mux_uninit(gmac->mux_handle);
+}
+
static int sun8i_dwmac_set_syscon(struct device *dev,
struct plat_stmmacenet_data *plat)
{
@@ -1153,8 +1159,6 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
struct stmmac_resources stmmac_res;
struct sunxi_priv_data *gmac;
struct device *dev = &pdev->dev;
- struct stmmac_priv *priv;
- struct net_device *ndev;
struct regmap *regmap;
int ret;
@@ -1237,6 +1241,9 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
ret = get_ephy_nodes(dev, gmac);
if (ret)
return ret;
+
+ plat_dat->mdio_init = sun8i_dwmac_register_mdio_mux;
+ plat_dat->mdio_exit = sun8i_dwmac_unregister_mdio_mux;
}
ret = sun8i_dwmac_set_syscon(&pdev->dev, plat_dat);
@@ -1247,33 +1254,8 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
if (ret)
goto dwmac_syscon;
- ndev = dev_get_drvdata(&pdev->dev);
- priv = netdev_priv(ndev);
-
- /* the MAC is runtime suspended after stmmac_dvr_probe(), so we
- * need to ensure the MAC resume back before other operations such
- * as reset.
- */
- pm_runtime_get_sync(&pdev->dev);
-
- /* The mux must be registered after parent MDIO
- * so after stmmac_dvr_probe()
- */
- if (gmac->variant->soc_has_internal_phy) {
- ret = sun8i_dwmac_register_mdio_mux(priv);
- if (ret) {
- dev_err(&pdev->dev, "Failed to register mux\n");
- goto dwmac_remove;
- }
- }
-
- pm_runtime_put(&pdev->dev);
-
return 0;
-dwmac_remove:
- pm_runtime_put_noidle(&pdev->dev);
- stmmac_pltfr_remove(pdev);
dwmac_syscon:
sun8i_dwmac_unset_syscon(gmac);
dwmac_ephy:
@@ -1289,9 +1271,6 @@ static void sun8i_dwmac_remove(struct platform_device *pdev)
struct stmmac_priv *priv = netdev_priv(ndev);
struct sunxi_priv_data *gmac = priv->plat->bsp_priv;
- if (gmac->variant->soc_has_internal_phy)
- mdio_mux_uninit(gmac->mux_handle);
-
stmmac_pltfr_remove(pdev);
reset_control_put(gmac->rst_ephy);
clk_put(gmac->ephy_clk);
--
2.55.0
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads