[PATCH net] net: stmmac: remove STMMAC_DOWN
Maxime Chevallier
maxime.chevallier at bootlin.com
Wed Dec 2 01:04:43 PST 2026
Hi,
On 12/1/26 10:12, Zxyan Zhu wrote:
> 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 at bootlin.com>
> Link: https://lore.kernel.org/netdev/20240327110142.159851-1-cathy.cai@unisoc.com/
> Signed-off-by: Zxyan Zhu <zxyan0222 at gmail.com>
Thanks for working on this. The commit log is quite verbose and the
"why" is drowned in details, if you need to resend when sashiko/clashiko
look at this, feel free to reduce a bit the commit message or even
better, write it by hand :)
Anyway,
Reviewed-by: Maxime Chevallier <maxime.chevallier at bootlin.com>
Maxime
More information about the linux-arm-kernel
mailing list