]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: stmmac: dwc-qos-eth: move MDIO bus locking into stmmac_mdio
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Wed, 15 Oct 2025 16:10:41 +0000 (17:10 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 16 Oct 2025 22:58:21 +0000 (15:58 -0700)
Rather than dwc-qos-eth manipulating the MDIO bus lock directly, add
helpers to the stmmac MDIO layer and use them in dwc-qos-eth. This
improves my commit 87f43e6f06a2 ("net: stmmac: dwc-qos: calibrate tegra
with mdio bus idle").

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/E1v945J-0000000AmeJ-1GOb@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
drivers/net/ethernet/stmicro/stmmac/stmmac.h
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c

index e8539cad4602e82aa4163fb4bfadd25e5910c66a..f1c2e35badf72f1c6cbe6076848349ea26b4f0f9 100644 (file)
@@ -162,7 +162,7 @@ static void tegra_eqos_fix_speed(void *bsp_priv, int speed, unsigned int mode)
                priv = netdev_priv(dev_get_drvdata(eqos->dev));
 
                /* Calibration should be done with the MDIO bus idle */
-               mutex_lock(&priv->mii->mdio_lock);
+               stmmac_mdio_lock(priv);
 
                /* calibrate */
                value = readl(eqos->regs + SDMEMCOMPPADCTRL);
@@ -198,7 +198,7 @@ static void tegra_eqos_fix_speed(void *bsp_priv, int speed, unsigned int mode)
                value &= ~SDMEMCOMPPADCTRL_PAD_E_INPUT_OR_E_PWRD;
                writel(value, eqos->regs + SDMEMCOMPPADCTRL);
 
-               mutex_unlock(&priv->mii->mdio_lock);
+               stmmac_mdio_unlock(priv);
        } else {
                value = readl(eqos->regs + AUTO_CAL_CONFIG);
                value &= ~AUTO_CAL_CONFIG_ENABLE;
index 7ca5477be390b9b7495b734318adb58eeca5884c..ec8bddc1c37fe3cf3d22b1a397b07e2904c81ebc 100644 (file)
@@ -388,6 +388,8 @@ static inline bool stmmac_wol_enabled_phy(struct stmmac_priv *priv)
 int stmmac_mdio_unregister(struct net_device *ndev);
 int stmmac_mdio_register(struct net_device *ndev);
 int stmmac_mdio_reset(struct mii_bus *mii);
+void stmmac_mdio_lock(struct stmmac_priv *priv);
+void stmmac_mdio_unlock(struct stmmac_priv *priv);
 int stmmac_pcs_setup(struct net_device *ndev);
 void stmmac_pcs_clean(struct net_device *ndev);
 void stmmac_set_ethtool_ops(struct net_device *netdev);
index f408737f6fc73e3cd2d3c72361078cfa6b3442f0..d62b2870899d5d277b9e30787805bb81e86b1cd3 100644 (file)
@@ -734,3 +734,17 @@ int stmmac_mdio_unregister(struct net_device *ndev)
 
        return 0;
 }
+
+void stmmac_mdio_lock(struct stmmac_priv *priv)
+{
+       if (priv->mii)
+               mutex_lock(&priv->mii->mdio_lock);
+}
+EXPORT_SYMBOL_GPL(stmmac_mdio_lock);
+
+void stmmac_mdio_unlock(struct stmmac_priv *priv)
+{
+       if (priv->mii)
+               mutex_unlock(&priv->mii->mdio_lock);
+}
+EXPORT_SYMBOL_GPL(stmmac_mdio_unlock);