From: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
To: Zxyan Zhu <zxyan0222@gmail.com>
Cc: Maxime Chevallier <maxime.chevallier@bootlin.com>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
Jose Abreu <Jose.Abreu@synopsys.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
ClarkWilliams <clrkwllms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Stanislav Fomichev <sdf@fomichev.me>,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-rt-devel@lists.linux.dev, bpf@vger.kernel.org
Subject: Re: [PATCH net] net: stmmac: remove STMMAC_DOWN
Date: Fri, 4 Dec 2026 10:09:03 +0100 [thread overview]
Message-ID: <axKDL2SQzua5MIH3@lore-desk> (raw)
In-Reply-To: <20261201091256.3000677-1-zxyan0222@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 8167 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>
Reviewed-by: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.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
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
prev parent reply other threads:[~2026-12-04 9:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 9:12 [PATCH net] net: stmmac: remove STMMAC_DOWN Zxyan Zhu
2026-12-02 9:04 ` Maxime Chevallier
2026-12-02 11:33 ` zhu xin
2026-12-02 9:13 ` sashiko-bot
2026-12-03 9:15 ` netdev-bot+sashiko
2026-12-03 9:45 ` zhu xin
2026-12-04 9:09 ` Lorenzo Bianconi [this message]
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=axKDL2SQzua5MIH3@lore-desk \
--to=lorenzo.bianconi@oss.qualcomm.com \
--cc=Jose.Abreu@synopsys.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=bpf@vger.kernel.org \
--cc=clrkwllms@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rostedt@goodmis.org \
--cc=sdf@fomichev.me \
--cc=zxyan0222@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.