Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Zxyan Zhu
Tue, 01 Dec 2026 09:12
[PATCH net] net: stmmac: remove STMMAC_DOWN
Author: Zxyan Zhu
Date: Tue, 01 Dec 2026 09:12
Date: Tue, 01 Dec 2026 09:12
192 lines
18703 bytes
18703 bytes
STMMAC_DOWN was introduced by commit 34877a15f787 ("net: stmmac: Rework and fix
TX Timeout code") to mark the window where stmmac_reset_subtask() runs
dev_close()/dev_open(). However, the flag is only ever set and cleared
inside stmmac_reset_subtask(), yet most of its call sites treat it as if
it meant "interface is down". That mismatch is not just misleading, it
is the source of an interrupt storm.
On a PREEMPT_RT system, fault-injecting an uncorrectable dwxgmac2 safety
error (src3 FSM RX parity) while traffic is running makes
stmmac_global_err() schedule stmmac_reset_subtask(), which does
dev_close()/dev_open(). While dev_close() blocks in synchronize_net()
waiting for an RCU grace period, a pending level-triggered DMA interrupt
makes the handlers bail out early:
/* Check if adapter is up */
if (test_bit(STMMAC_DOWN, &priv->state))
return IRQ_HANDLED;
without clearing any interrupt status. The level IRQ stays asserted, the
interrupt counter storms from ~2.7k to ~14M in about 28 s (~500k irqs/s),
starving the rcuc kthread so the RCU grace period never completes:
rcu: INFO: rcu_preempt self-detected stall on CPU
rcu: 0-....: (7499 ticks this GP) ... rcuc=7499 jiffies(starved)
__wait_rcu_gp
synchronize_rcu_normal
synchronize_rcu_expedited
synchronize_net
dev_deactivate_many
__dev_close_many
netif_close_many
netif_close
dev_close
stmmac_service_task
The board then panics on panic_on_rcu_stall.
The STMMAC_DOWN early-returns do not actually protect anything: the
concurrent teardown is already serialized by free_irq(), which
synchronizes with in-flight handlers before freeing the DMA descriptors,
so the interrupt handlers can run normally during the reset window.
Remove the flag entirely and let the handlers clear the interrupt status
as they normally do. This matches the direction suggested by the stmmac
maintainer: the flag only causes problems while the call sites already
work without it.
The remaining uses are covered by existing mechanisms instead of a
dedicated flag: stmmac_service_event_schedule() is already guarded by
STMMAC_SERVICE_SCHED; stmmac_xdp_xmit() and stmmac_xsk_wakeup() now test
STMMAC_RESETING, which stmmac_reset_subtask() sets before dev_close() and
clears after dev_open(), so the whole reset window (including the
ndo_open() half, where netif_running() is already true before the DMA
rings are rebuilt) is rejected; and stmmac_reset_subtask() is guarded by
STMMAC_RESET_REQUESTED plus STMMAC_RESETING.
With the fix, on a local board (dwxgmac2), injecting the same safety
error while traffic is running completes the reset cleanly and the main
IRQ counter no longer storms.
Fixes: 34877a15f787 ("net: stmmac: Rework and fix TX Timeout code")
Suggested-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://lore.kernel.org/netdev/20240327110142.159851-1-cathy.cai@unisoc.com/
Signed-off-by: Zxyan Zhu <zxyan0222@gmail.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 -
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 32 ++-----------------
2 files changed, 3 insertions(+), 30 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index b76acfe0d958..f5c0ff3af1d2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -397,7 +397,6 @@ struct stmmac_priv {
};
enum stmmac_state {
- STMMAC_DOWN,
STMMAC_RESET_REQUESTED,
STMMAC_RESETING,
STMMAC_SERVICE_SCHED,
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index a685ce4638f6..7f7be965604e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -337,8 +337,7 @@ static void stmmac_enable_all_queues(struct stmmac_priv *priv)
static void stmmac_service_event_schedule(struct stmmac_priv *priv)
{
- if (!test_bit(STMMAC_DOWN, &priv->state) &&
- !test_and_set_bit(STMMAC_SERVICE_SCHED, &priv->state))
+ if (!test_and_set_bit(STMMAC_SERVICE_SCHED, &priv->state))
queue_work(priv->wq, &priv->service_task);
}
@@ -6487,10 +6486,6 @@ static irqreturn_t stmmac_interrupt(int irq, void *dev_id)
struct net_device *dev = (struct net_device *)dev_id;
struct stmmac_priv *priv = netdev_priv(dev);
- /* Check if adapter is up */
- if (test_bit(STMMAC_DOWN, &priv->state))
- return IRQ_HANDLED;
-
/* Check ASP error if it isn't delivered via an individual IRQ */
if (priv->sfty_irq <= 0 && stmmac_safety_feat_interrupt(priv))
return IRQ_HANDLED;
@@ -6509,10 +6504,6 @@ static irqreturn_t stmmac_mac_interrupt(int irq, void *dev_id)
struct net_device *dev = (struct net_device *)dev_id;
struct stmmac_priv *priv = netdev_priv(dev);
- /* Check if adapter is up */
- if (test_bit(STMMAC_DOWN, &priv->state))
- return IRQ_HANDLED;
-
/* To handle Common interrupts */
stmmac_common_interrupt(priv);
@@ -6527,10 +6518,6 @@ static irqreturn_t stmmac_safety_interrupt(int irq, void *dev_id)
struct net_device *dev = (struct net_device *)dev_id;
struct stmmac_priv *priv = netdev_priv(dev);
- /* Check if adapter is up */
- if (test_bit(STMMAC_DOWN, &priv->state))
- return IRQ_HANDLED;
-
/* Check if a fatal error happened */
stmmac_safety_feat_interrupt(priv);
@@ -6548,10 +6535,6 @@ static irqreturn_t stmmac_msi_intr_tx(int irq, void *data)
dma_conf = container_of(tx_q, struct stmmac_dma_conf, tx_queue[chan]);
priv = container_of(dma_conf, struct stmmac_priv, dma_conf);
- /* Check if adapter is up */
- if (test_bit(STMMAC_DOWN, &priv->state))
- return IRQ_HANDLED;
-
status = stmmac_napi_check(priv, chan, DMA_DIR_TX);
if (unlikely(status & tx_hard_error_bump_tc)) {
@@ -6574,10 +6557,6 @@ static irqreturn_t stmmac_msi_intr_rx(int irq, void *data)
dma_conf = container_of(rx_q, struct stmmac_dma_conf, rx_queue[chan]);
priv = container_of(dma_conf, struct stmmac_priv, dma_conf);
- /* Check if adapter is up */
- if (test_bit(STMMAC_DOWN, &priv->state))
- return IRQ_HANDLED;
-
stmmac_napi_check(priv, chan, DMA_DIR_RX);
return IRQ_HANDLED;
@@ -7150,7 +7129,7 @@ static int stmmac_xdp_xmit(struct net_device *dev, int num_frames,
int i, nxmit = 0;
int queue;
- if (unlikely(test_bit(STMMAC_DOWN, &priv->state)))
+ if (unlikely(test_bit(STMMAC_RESETING, &priv->state)))
return -ENETDOWN;
if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
@@ -7418,7 +7397,7 @@ int stmmac_xsk_wakeup(struct net_device *dev, u32 queue, u32 flags)
struct stmmac_tx_queue *tx_q;
struct stmmac_channel *ch;
- if (test_bit(STMMAC_DOWN, &priv->state) ||
+ if (test_bit(STMMAC_RESETING, &priv->state) ||
!netif_carrier_ok(priv->dev))
return -ENETDOWN;
@@ -7527,9 +7506,6 @@ static void stmmac_reset_subtask(struct stmmac_priv *priv)
{
if (!test_and_clear_bit(STMMAC_RESET_REQUESTED, &priv->state))
return;
- if (test_bit(STMMAC_DOWN, &priv->state))
- return;
-
netdev_err(priv->dev, "Reset adapter.\n");
rtnl_lock();
@@ -7537,10 +7513,8 @@ static void stmmac_reset_subtask(struct stmmac_priv *priv)
while (test_and_set_bit(STMMAC_RESETING, &priv->state))
usleep_range(1000, 2000);
- set_bit(STMMAC_DOWN, &priv->state);
dev_close(priv->dev);
dev_open(priv->dev, NULL);
- clear_bit(STMMAC_DOWN, &priv->state);
clear_bit(STMMAC_RESETING, &priv->state);
rtnl_unlock();
}
--
2.34.1
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