From: yangg9 <cohenyang511@gmail.com>
To: netdev@vger.kernel.org
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, kuba@kernel.org,
yangg9 <yangg9@xiaopeng.com>
Subject: [PATCH] net: stmmac: Reorder cleanup sequence and disable IRQ earlier in reset path
Date: Tue, 17 Mar 2026 20:19:37 +0800 [thread overview]
Message-ID: <20260317121937.109211-1-yangg9@xiaopeng.com> (raw)
The recent changes restructure resource cleanup in __stmmac_release() to
free IRQ lines, stop DMA, and release descriptors before stopping the PHY,
ensuring resources are properly cleaned up in the correct order.
Additionally, in stmmac_reset_subtask(), disable IRQ as early as possible
after acquiring the STMMAC_RESETING lock to prevent spurious interrupts
that could access device state during the DOWN transition, reducing race
conditions between interrupt handlers and device state transitions.
This improves the robustness of both the release and reset paths by
enforcing stricter ordering guarantees on resource cleanup and interrupt
handling.
Signed-off-by: yangg9 <yangg9@xiaopeng.com>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 21 +++++++++++--------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 124d7a00f9f0..fa06b2eb33f2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -4202,6 +4202,15 @@ static void __stmmac_release(struct net_device *dev)
struct stmmac_priv *priv = netdev_priv(dev);
u8 chan;
+ /* Free the IRQ lines */
+ stmmac_free_irq(dev, REQ_IRQ_ERR_ALL, 0);
+
+ /* Stop TX/RX DMA and clear the descriptors */
+ stmmac_stop_all_dma(priv);
+
+ /* Release and free the Rx/Tx resources */
+ free_dma_desc_resources(priv, &priv->dma_conf);
+
/* Stop and disconnect the PHY */
phylink_stop(priv->phylink);
@@ -4212,15 +4221,6 @@ static void __stmmac_release(struct net_device *dev)
netif_tx_disable(dev);
- /* Free the IRQ lines */
- stmmac_free_irq(dev, REQ_IRQ_ERR_ALL, 0);
-
- /* Stop TX/RX DMA and clear the descriptors */
- stmmac_stop_all_dma(priv);
-
- /* Release and free the Rx/Tx resources */
- free_dma_desc_resources(priv, &priv->dma_conf);
-
stmmac_release_ptp(priv);
if (stmmac_fpe_supported(priv))
@@ -7331,6 +7331,9 @@ static void stmmac_reset_subtask(struct stmmac_priv *priv)
while (test_and_set_bit(STMMAC_RESETING, &priv->state))
usleep_range(1000, 2000);
+ /* Close IRQ entry as early as possible before DOWN short-circuit path. */
+ disable_irq_nosync(priv->dev->irq);
+
set_bit(STMMAC_DOWN, &priv->state);
dev_close(priv->dev);
dev_open(priv->dev, NULL);
--
2.43.0
next reply other threads:[~2026-03-17 12:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-17 12:19 yangg9 [this message]
2026-03-19 12:46 ` net: stmmac: Reorder cleanup sequence and disable IRQ earlier in reset path Paolo Abeni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260317121937.109211-1-yangg9@xiaopeng.com \
--to=cohenyang511@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=yangg9@xiaopeng.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox