Skip to contentSkip to conversation

net: stmmac: more cleanups

PATCH Applied Russell King (Oracle) 6 participants 18 messages Oct 15, 2025 – Oct 16, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover net: stmmac: more cleanups

The subject for the cover message is wearing thin as I've used it a number of times, but the scope for cleaning up the driver continues, and continue it will do, because this is just a small fraction of the queue.

1. make a better job of one of my previous commits, moving the holding of the lock into stmmac_mdio.c

2. move the mac_finish() method to be in-order with the layout of struct phylink_mac_ops - this order was chosen because it reflects the order that the methods are called, thus making the flow more obvious when reading code.

3. continuing on the "removal of stuff that doesn't need to happen", patch 3 removes the phylink_speed_(up|down) out of the path that is used for MTU changes - we really don't need to fiddle with the PHY advertisement when changing the MTU!

4. clean up tc_init()'s initialisation of flow_entries_max - this is the sole place that this is written, and we might as well make the code more easy to follow.

5. stmmac_phy_setup() really confuses me when I read the code, it's not really about PHY setup, but about phylink setup. So, name its name reflect its functionality.

 .../ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c    |  4 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac.h       |  2 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  | 49 +++++++++++-----------
 drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c  | 14 +++++++
 drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c    |  6 +--
 5 files changed, 46 insertions(+), 29 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
#1 lore raw

PATCH 1/5 net: stmmac: dwc-qos-eth: move MDIO bus locking into stmmac_mdio

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").

---
 .../ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c    |  4 ++--
 drivers/net/ethernet/stmicro/stmmac/stmmac.h       |  2 ++
 drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c  | 14 ++++++++++++++
 3 files changed, 18 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +2 -2
index e8539cad4602..f1c2e35badf7 100644
@@ -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;
drivers/net/ethernet/stmicro/stmmac/stmmac.h +2 -0
index 7ca5477be390..ec8bddc1c37f 100644
@@ -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);
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +14 -0
index f408737f6fc7..d62b2870899d 100644
@@ -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);
Signature · 1 line
2.47.3
#4 lore raw

PATCH 2/5 net: stmmac: place .mac_finish() method more appropriately

In reply to Russell King (Oracle)

Place the .mac_finish() initialiser and implementation after the .mac_config() initialiser and method which reflects the order that they appear in struct phylink_mac_ops, and the order in which they are called. This keeps logically similar code together.

---
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 26 +++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +13 -13
index 650d75b73e0b..3728afa701c6 100644
@@ -859,6 +859,18 @@ static void stmmac_mac_config(struct phylink_config *config, unsigned int mode,
 	/* Nothing to do, xpcs_config() handles everything */
 }
 
+static int stmmac_mac_finish(struct phylink_config *config, unsigned int mode,
+			     phy_interface_t interface)
+{
+	struct net_device *ndev = to_net_dev(config->dev);
+	struct stmmac_priv *priv = netdev_priv(ndev);
+
+	if (priv->plat->mac_finish)
+		priv->plat->mac_finish(ndev, priv->plat->bsp_priv, mode, interface);
+
+	return 0;
+}
+
 static void stmmac_mac_link_down(struct phylink_config *config,
 				 unsigned int mode, phy_interface_t interface)
 {
@@ -1053,27 +1065,15 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer,
 	return 0;
 }
 
-static int stmmac_mac_finish(struct phylink_config *config, unsigned int mode,
-			     phy_interface_t interface)
-{
-	struct net_device *ndev = to_net_dev(config->dev);
-	struct stmmac_priv *priv = netdev_priv(ndev);
-
-	if (priv->plat->mac_finish)
-		priv->plat->mac_finish(ndev, priv->plat->bsp_priv, mode, interface);
-
-	return 0;
-}
-
 static const struct phylink_mac_ops stmmac_phylink_mac_ops = {
 	.mac_get_caps = stmmac_mac_get_caps,
 	.mac_select_pcs = stmmac_mac_select_pcs,
 	.mac_config = stmmac_mac_config,
+	.mac_finish = stmmac_mac_finish,
 	.mac_link_down = stmmac_mac_link_down,
 	.mac_link_up = stmmac_mac_link_up,
 	.mac_disable_tx_lpi = stmmac_mac_disable_tx_lpi,
 	.mac_enable_tx_lpi = stmmac_mac_enable_tx_lpi,
-	.mac_finish = stmmac_mac_finish,
 };
 
 /**
Signature · 1 line
2.47.3
#7 lore raw

PATCH 3/5 net: stmmac: avoid PHY speed change when configuring MTU

In reply to Russell King (Oracle)

There is no need to do the speed-down, speed-up dance when changing the MTU as there is little power saving that can be gained from such a brief interval between these, and the autonegotiation they cause takes much longer.

Move the calls to phylink_speed_up() and phylink_speed_down() into stmmac_open() and stmmac_release() respectively, reducing the work done in the __-variants of these functions.

---
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +10 -9
index 3728afa701c6..500cfd19e6b5 100644
@@ -3963,8 +3963,6 @@ static int __stmmac_open(struct net_device *dev,
 	stmmac_init_coalesce(priv);
 
 	phylink_start(priv->phylink);
-	/* We may have called phylink_speed_down before */
-	phylink_speed_up(priv->phylink);
 
 	ret = stmmac_request_irq(dev);
 	if (ret)
@@ -4015,6 +4013,9 @@ static int stmmac_open(struct net_device *dev)
 
 	kfree(dma_conf);
 
+	/* We may have called phylink_speed_down before */
+	phylink_speed_up(priv->phylink);
+
 	return ret;
 
 err_disconnect_phy:
@@ -4032,13 +4033,6 @@ static void __stmmac_release(struct net_device *dev)
 	struct stmmac_priv *priv = netdev_priv(dev);
 	u32 chan;
 
-	/* If the PHY or MAC has WoL enabled, then the PHY will not be
-	 * suspended when phylink_stop() is called below. Set the PHY
-	 * to its slowest speed to save power.
-	 */
-	if (device_may_wakeup(priv->device))
-		phylink_speed_down(priv->phylink, false);
-
 	/* Stop and disconnect the PHY */
 	phylink_stop(priv->phylink);
 
@@ -4078,6 +4072,13 @@ static int stmmac_release(struct net_device *dev)
 {
 	struct stmmac_priv *priv = netdev_priv(dev);
 
+	/* If the PHY or MAC has WoL enabled, then the PHY will not be
+	 * suspended when phylink_stop() is called below. Set the PHY
+	 * to its slowest speed to save power.
+	 */
+	if (device_may_wakeup(priv->device))
+		phylink_speed_down(priv->phylink, false);
+
 	__stmmac_release(dev);
 
 	phylink_disconnect_phy(priv->phylink);
Signature · 1 line
2.47.3
#11 lore raw

PATCH 4/5 net: stmmac: rearrange tc_init()

In reply to Russell King (Oracle)

To make future changes easier, rearrange the use of dma_cap->l3l4fnum vs priv->flow_entries_max.

Always initialise priv->flow_entries_max from dma_cap->l3l4fnum, then use priv->flow_entries_max to determine whether we allocate priv->flow_entries and set it up.

This change is safe because tc_init() is only called once from stmmac_dvr_probe().

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +3 -3
index 97e89a604abd..ef65cf511f3e 100644
@@ -262,10 +262,10 @@ static int tc_init(struct stmmac_priv *priv)
 	unsigned int count;
 	int ret, i;
 
-	if (dma_cap->l3l4fnum) {
-		priv->flow_entries_max = dma_cap->l3l4fnum;
+	priv->flow_entries_max = dma_cap->l3l4fnum;
+	if (priv->flow_entries_max) {
 		priv->flow_entries = devm_kcalloc(priv->device,
-						  dma_cap->l3l4fnum,
+						  priv->flow_entries_max,
 						  sizeof(*priv->flow_entries),
 						  GFP_KERNEL);
 		if (!priv->flow_entries)
Signature · 1 line
2.47.3
#13 lore raw

PATCH 5/5 net: stmmac: rename stmmac_phy_setup() to include phylink

In reply to Russell King (Oracle)

stmmac_phy_setup() does not set up any PHY, but does setup phylink. Rename this function to stmmac_phylink_setup() to reflect more what it is doing.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -2
index 500cfd19e6b5..c9fa965c8566 100644
@@ -1185,7 +1185,7 @@ static int stmmac_init_phy(struct net_device *dev)
 	return 0;
 }
 
-static int stmmac_phy_setup(struct stmmac_priv *priv)
+static int stmmac_phylink_setup(struct stmmac_priv *priv)
 {
 	struct stmmac_mdio_bus_data *mdio_bus_data;
 	struct phylink_config *config;
@@ -7642,7 +7642,7 @@ int stmmac_dvr_probe(struct device *device,
 	if (ret)
 		goto error_pcs_setup;
 
-	ret = stmmac_phy_setup(priv);
+	ret = stmmac_phylink_setup(priv);
 	if (ret) {
 		netdev_err(ndev, "failed to setup phy (%d)\n", ret);
 		goto error_phy_setup;
Signature · 1 line
2.47.3
maintainer Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH net-next 1/5] net: stmmac: dwc-qos-eth: move MDIO bus locking into stmmac_mdio

In reply to Russell King (Oracle)
Quoted 6 lines

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").

maintainer Reviewed-by on v1 2/5
#5 lore raw

Re: [PATCH net-next 2/5] net: stmmac: place .mac_finish() method more appropriately

In reply to Russell King (Oracle)
Quoted 6 lines · Russell King (Oracle)

Place the .mac_finish() initialiser and implementation after the .mac_config() initialiser and method which reflects the order that they appear in struct phylink_mac_ops, and the order in which they are called. This keeps logically similar code together.

Quoted 56 lines
---
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 26 +++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +13 -13
index 650d75b73e0b..3728afa701c6 100644
@@ -859,6 +859,18 @@ static void stmmac_mac_config(struct phylink_config *config, unsigned int mode,
 	/* Nothing to do, xpcs_config() handles everything */
 }
 
+static int stmmac_mac_finish(struct phylink_config *config, unsigned int mode,
+			     phy_interface_t interface)
+{
+	struct net_device *ndev = to_net_dev(config->dev);
+	struct stmmac_priv *priv = netdev_priv(ndev);
+
+	if (priv->plat->mac_finish)
+		priv->plat->mac_finish(ndev, priv->plat->bsp_priv, mode, interface);
+
+	return 0;
+}
+
 static void stmmac_mac_link_down(struct phylink_config *config,
 				 unsigned int mode, phy_interface_t interface)
 {
@@ -1053,27 +1065,15 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer,
 	return 0;
 }
 
-static int stmmac_mac_finish(struct phylink_config *config, unsigned int mode,
-			     phy_interface_t interface)
-{
-	struct net_device *ndev = to_net_dev(config->dev);
-	struct stmmac_priv *priv = netdev_priv(ndev);
-
-	if (priv->plat->mac_finish)
-		priv->plat->mac_finish(ndev, priv->plat->bsp_priv, mode, interface);
-
-	return 0;
-}
-
 static const struct phylink_mac_ops stmmac_phylink_mac_ops = {
 	.mac_get_caps = stmmac_mac_get_caps,
 	.mac_select_pcs = stmmac_mac_select_pcs,
 	.mac_config = stmmac_mac_config,
+	.mac_finish = stmmac_mac_finish,
 	.mac_link_down = stmmac_mac_link_down,
 	.mac_link_up = stmmac_mac_link_up,
 	.mac_disable_tx_lpi = stmmac_mac_disable_tx_lpi,
 	.mac_enable_tx_lpi = stmmac_mac_enable_tx_lpi,
-	.mac_finish = stmmac_mac_finish,
 };
 
 /**
maintainer Reviewed-by on v1 3/5
#8 lore raw

Re: [PATCH net-next 3/5] net: stmmac: avoid PHY speed change when configuring MTU

In reply to Russell King (Oracle)
Quoted 10 lines · Russell King (Oracle)

There is no need to do the speed-down, speed-up dance when changing the MTU as there is little power saving that can be gained from such a brief interval between these, and the autonegotiation they cause takes much longer.

Move the calls to phylink_speed_up() and phylink_speed_down() into stmmac_open() and stmmac_release() respectively, reducing the work done in the __-variants of these functions.

Quoted 55 lines
---
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +10 -9
index 3728afa701c6..500cfd19e6b5 100644
@@ -3963,8 +3963,6 @@ static int __stmmac_open(struct net_device *dev,
 	stmmac_init_coalesce(priv);
 
 	phylink_start(priv->phylink);
-	/* We may have called phylink_speed_down before */
-	phylink_speed_up(priv->phylink);
 
 	ret = stmmac_request_irq(dev);
 	if (ret)
@@ -4015,6 +4013,9 @@ static int stmmac_open(struct net_device *dev)
 
 	kfree(dma_conf);
 
+	/* We may have called phylink_speed_down before */
+	phylink_speed_up(priv->phylink);
+
 	return ret;
 
 err_disconnect_phy:
@@ -4032,13 +4033,6 @@ static void __stmmac_release(struct net_device *dev)
 	struct stmmac_priv *priv = netdev_priv(dev);
 	u32 chan;
 
-	/* If the PHY or MAC has WoL enabled, then the PHY will not be
-	 * suspended when phylink_stop() is called below. Set the PHY
-	 * to its slowest speed to save power.
-	 */
-	if (device_may_wakeup(priv->device))
-		phylink_speed_down(priv->phylink, false);
-
 	/* Stop and disconnect the PHY */
 	phylink_stop(priv->phylink);
 
@@ -4078,6 +4072,13 @@ static int stmmac_release(struct net_device *dev)
 {
 	struct stmmac_priv *priv = netdev_priv(dev);
 
+	/* If the PHY or MAC has WoL enabled, then the PHY will not be
+	 * suspended when phylink_stop() is called below. Set the PHY
+	 * to its slowest speed to save power.
+	 */
+	if (device_may_wakeup(priv->device))
+		phylink_speed_down(priv->phylink, false);
+
 	__stmmac_release(dev);
 
 	phylink_disconnect_phy(priv->phylink);
maintainer Reviewed-by on v1 4/5
#12 lore raw

Re: [PATCH net-next 4/5] net: stmmac: rearrange tc_init()

In reply to Russell King (Oracle)
Quoted 11 lines · Russell King (Oracle)

To make future changes easier, rearrange the use of dma_cap->l3l4fnum vs priv->flow_entries_max.

Always initialise priv->flow_entries_max from dma_cap->l3l4fnum, then use priv->flow_entries_max to determine whether we allocate priv->flow_entries and set it up.

This change is safe because tc_init() is only called once from stmmac_dvr_probe().

Quoted 22 lines
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +3 -3
index 97e89a604abd..ef65cf511f3e 100644
@@ -262,10 +262,10 @@ static int tc_init(struct stmmac_priv *priv)
 	unsigned int count;
 	int ret, i;
 
-	if (dma_cap->l3l4fnum) {
-		priv->flow_entries_max = dma_cap->l3l4fnum;
+	priv->flow_entries_max = dma_cap->l3l4fnum;
+	if (priv->flow_entries_max) {
 		priv->flow_entries = devm_kcalloc(priv->device,
-						  dma_cap->l3l4fnum,
+						  priv->flow_entries_max,
 						  sizeof(*priv->flow_entries),
 						  GFP_KERNEL);
 		if (!priv->flow_entries)
maintainer Reviewed-by on v1 5/5
#14 lore raw

Re: [PATCH net-next 5/5] net: stmmac: rename stmmac_phy_setup() to include phylink

In reply to Russell King (Oracle)
Quoted 5 lines · Russell King (Oracle)

stmmac_phy_setup() does not set up any PHY, but does setup phylink. Rename this function to stmmac_phylink_setup() to reflect more what it is doing.

Quoted 26 lines
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -2
index 500cfd19e6b5..c9fa965c8566 100644
@@ -1185,7 +1185,7 @@ static int stmmac_init_phy(struct net_device *dev)
 	return 0;
 }
 
-static int stmmac_phy_setup(struct stmmac_priv *priv)
+static int stmmac_phylink_setup(struct stmmac_priv *priv)
 {
 	struct stmmac_mdio_bus_data *mdio_bus_data;
 	struct phylink_config *config;
@@ -7642,7 +7642,7 @@ int stmmac_dvr_probe(struct device *device,
 	if (ret)
 		goto error_pcs_setup;
 
-	ret = stmmac_phy_setup(priv);
+	ret = stmmac_phylink_setup(priv);
 	if (ret) {
 		netdev_err(ndev, "failed to setup phy (%d)\n", ret);
 		goto error_phy_setup;
Reviewed-by on v1 5/5
#15 lore raw

Re: [Linux-stm32] [PATCH net-next 5/5] net: stmmac: rename stmmac_phy_setup() to include phylink

In reply to Russell King (Oracle)
Quoted 5 lines · Russell King (Oracle)

stmmac_phy_setup() does not set up any PHY, but does setup phylink. Rename this function to stmmac_phylink_setup() to reflect more what it is doing.

Quoted 26 lines
---
  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -2
index 500cfd19e6b5..c9fa965c8566 100644
@@ -1185,7 +1185,7 @@ static int stmmac_init_phy(struct net_device *dev)
  	return 0;
  }
 
-static int stmmac_phy_setup(struct stmmac_priv *priv)
+static int stmmac_phylink_setup(struct stmmac_priv *priv)
  {
  	struct stmmac_mdio_bus_data *mdio_bus_data;
  	struct phylink_config *config;
@@ -7642,7 +7642,7 @@ int stmmac_dvr_probe(struct device *device,
  	if (ret)
  		goto error_pcs_setup;
 
-	ret = stmmac_phy_setup(priv);
+	ret = stmmac_phylink_setup(priv);
  	if (ret) {
  		netdev_err(ndev, "failed to setup phy (%d)\n", ret);
  		goto error_phy_setup;
Reviewed-by on v1 3/5
#9 lore raw

Re: [Linux-stm32] [PATCH net-next 3/5] net: stmmac: avoid PHY speed change when configuring MTU

In reply to Russell King (Oracle)
Quoted 10 lines · Russell King (Oracle)

There is no need to do the speed-down, speed-up dance when changing the MTU as there is little power saving that can be gained from such a brief interval between these, and the autonegotiation they cause takes much longer.

Move the calls to phylink_speed_up() and phylink_speed_down() into stmmac_open() and stmmac_release() respectively, reducing the work done in the __-variants of these functions.

Quoted 55 lines
---
  .../net/ethernet/stmicro/stmmac/stmmac_main.c | 19 ++++++++++---------
  1 file changed, 10 insertions(+), 9 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +10 -9
index 3728afa701c6..500cfd19e6b5 100644
@@ -3963,8 +3963,6 @@ static int __stmmac_open(struct net_device *dev,
  	stmmac_init_coalesce(priv);
 
  	phylink_start(priv->phylink);
-	/* We may have called phylink_speed_down before */
-	phylink_speed_up(priv->phylink);
 
  	ret = stmmac_request_irq(dev);
  	if (ret)
@@ -4015,6 +4013,9 @@ static int stmmac_open(struct net_device *dev)
 
  	kfree(dma_conf);
 
+	/* We may have called phylink_speed_down before */
+	phylink_speed_up(priv->phylink);
+
  	return ret;
 
  err_disconnect_phy:
@@ -4032,13 +4033,6 @@ static void __stmmac_release(struct net_device *dev)
  	struct stmmac_priv *priv = netdev_priv(dev);
  	u32 chan;
 
-	/* If the PHY or MAC has WoL enabled, then the PHY will not be
-	 * suspended when phylink_stop() is called below. Set the PHY
-	 * to its slowest speed to save power.
-	 */
-	if (device_may_wakeup(priv->device))
-		phylink_speed_down(priv->phylink, false);
-
  	/* Stop and disconnect the PHY */
  	phylink_stop(priv->phylink);
 
@@ -4078,6 +4072,13 @@ static int stmmac_release(struct net_device *dev)
  {
  	struct stmmac_priv *priv = netdev_priv(dev);
 
+	/* If the PHY or MAC has WoL enabled, then the PHY will not be
+	 * suspended when phylink_stop() is called below. Set the PHY
+	 * to its slowest speed to save power.
+	 */
+	if (device_may_wakeup(priv->device))
+		phylink_speed_down(priv->phylink, false);
+
  	__stmmac_release(dev);
 
  	phylink_disconnect_phy(priv->phylink);
Reviewed-by on v1 1/5
#3 lore raw

Re: [PATCH net-next 1/5] net: stmmac: dwc-qos-eth: move MDIO bus locking into stmmac_mdio

In reply to Russell King (Oracle)
Quoted 6 lines · Russell King (Oracle)

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").

Andrew

Reviewed-by on v1 2/5
#6 lore raw

Re: [PATCH net-next 2/5] net: stmmac: place .mac_finish() method more appropriately

In reply to Russell King (Oracle)
Quoted 6 lines · Russell King (Oracle)

Place the .mac_finish() initialiser and implementation after the .mac_config() initialiser and method which reflects the order that they appear in struct phylink_mac_ops, and the order in which they are called. This keeps logically similar code together.

Andrew

Reviewed-by on v1 3/5
#10 lore raw

Re: [PATCH net-next 3/5] net: stmmac: avoid PHY speed change when configuring MTU

In reply to Russell King (Oracle)
Quoted 10 lines · Russell King (Oracle)

There is no need to do the speed-down, speed-up dance when changing the MTU as there is little power saving that can be gained from such a brief interval between these, and the autonegotiation they cause takes much longer.

Move the calls to phylink_speed_up() and phylink_speed_down() into stmmac_open() and stmmac_release() respectively, reducing the work done in the __-variants of these functions.

Andrew

#17 lore raw
In reply to Russell King (Oracle)
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Wed, 15 Oct 2025 17:09:07 +0100 you wrote:

The subject for the cover message is wearing thin as I've used it a number of times, but the scope for cleaning up the driver continues, and continue it will do, because this is just a small fraction of the queue.

1. make a better job of one of my previous commits, moving the holding of the lock into stmmac_mdio.c

[...]

Here is the summary with links:
- [net-next,1/5] net: stmmac: dwc-qos-eth: move MDIO bus locking into stmmac_mdio

    https://git.kernel.org/netdev/net-next/c/12a7b7bc1427
  - [net-next,2/5] net: stmmac: place .mac_finish() method more appropriately
    https://git.kernel.org/netdev/net-next/c/0bc832a54d27
  - [net-next,3/5] net: stmmac: avoid PHY speed change when configuring MTU
    https://git.kernel.org/netdev/net-next/c/e82c64be9b45
  - [net-next,4/5] net: stmmac: rearrange tc_init()
    https://git.kernel.org/netdev/net-next/c/07d91ec99a8a
  - [net-next,5/5] net: stmmac: rename stmmac_phy_setup() to include phylink
    https://git.kernel.org/netdev/net-next/c/4a4094ba7ad2

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html