summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2025-02-28 11:11:57 +0000
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2025-04-04 14:39:29 +0100
commit45a52c56f31d429a9619f18b68e53d3165b7d137 (patch)
tree44c252fc1f30af266b3b9737fca0a609442a9405
parent70046a03a0bb8fad6f452486e9bf5471ffd60244 (diff)
net: stmmac: call phylink_start() and phylink_stop() in XDP functions
Phylink does not permit drivers to mess with the netif carrier, as this will de-synchronise phylink with the MAC driver. Moreover, setting and clearing the TE and RE bits via stmmac_mac_set() in this path is also wrong as the link may not be up. Replace the netif_carrier_on(), netif_carrier_off() and stmmac_mac_set() calls with the appropriate phylink_start() and phylink_stop() calls, thereby allowing phylink to manage the netif carrier and TE/RE bits through the .mac_link_up() and .mac_link_down() methods. Note that RE should only be set after the DMA is ready to avoid the receive FIFO between the MAC and DMA blocks overflowing, so phylink_start() needs to be placed after DMA has been started. Tested-by: Furong Xu <0x1207@gmail.com> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 12ce7e1b1868..aba4075f3665 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -6874,6 +6874,8 @@ void stmmac_xdp_release(struct net_device *dev)
/* Ensure tx function is not running */
netif_tx_disable(dev);
+ phylink_stop(priv->phylink);
+
/* Disable NAPI process */
stmmac_disable_all_queues(priv);
@@ -6889,14 +6891,10 @@ void stmmac_xdp_release(struct net_device *dev)
/* Release and free the Rx/Tx resources */
free_dma_desc_resources(priv, &priv->dma_conf);
- /* Disable the MAC Rx/Tx */
- stmmac_mac_set(priv, priv->ioaddr, false);
-
/* set trans_start so we don't get spurious
* watchdogs during reset
*/
netif_trans_update(dev);
- netif_carrier_off(dev);
}
int stmmac_xdp_open(struct net_device *dev)
@@ -6979,25 +6977,25 @@ int stmmac_xdp_open(struct net_device *dev)
tx_q->txtimer.function = stmmac_tx_timer;
}
- /* Enable the MAC Rx/Tx */
- stmmac_mac_set(priv, priv->ioaddr, true);
-
/* Start Rx & Tx DMA Channels */
stmmac_start_all_dma(priv);
+ phylink_start(priv->phylink);
+
ret = stmmac_request_irq(dev);
if (ret)
goto irq_error;
/* Enable NAPI process*/
stmmac_enable_all_queues(priv);
- netif_carrier_on(dev);
netif_tx_start_all_queues(dev);
stmmac_enable_all_dma_irq(priv);
return 0;
irq_error:
+ phylink_stop(priv->phylink);
+
for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++)
hrtimer_cancel(&priv->dma_conf.tx_queue[chan].txtimer);