Hi Maxime,
Thanks for the review. I saw the sashiko review result.
Regarding the use-after-free in stmmac_xdp_xmit() that sashiko flagged
(racing with XSK pool teardown): the old STMMAC_DOWN check never covered
that path either, so this patch doesn't change it. Since it's orthogonal
to the interrupt-storm fix here, I'd rather address it in a separate
patch than fold it into this one.
As for this patch, I'll keep it as v1 without resending.
Thanks,
Zxyan
On Wed, Dec 2, 2026 at 5:04 PM Maxime Chevallier
<maxi…@bootlin.com> wrote:
>
> 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 <maxi…@bootlin.com>
> > Link: https://lore.kernel.org/netdev/2024…@unisoc.com/
> > Signed-off-by: Zxyan Zhu <zxya…@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 <maxi…@bootlin.com>
>
> Maxime
>