From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.175 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796116388; b=Fl+SWbrE7dyelzGFyguoaWMpvgmk8xHQ1ML7mBIgaT4vuhDq/zVFGugqNvS2lwxqDbXc Ln9qQWgFWSbHvjztZ6CgaAFa5Nz/oCB+gIltJ7+pxTNyN5a7IDwJKdIO/WQzwL8Ec6R3f k0RZRfCQAMmR81rnvVqhesGPbX1s/9gsbTkt876FSwUK4V7eunKDiGlCPEKwtTPj6zapv L375mJxw0Do/z3Qfjn8LywPU8pHVIGN4UwY76ulZ0Xzs3qfA64wPaRy/7mZJSE2iVC0Hi Krw5edUYJD0em2kcWLuTMkz3aDZ986qyRU1wWRmxWSdjxcjQNfkCwXaoXDV8qh/AWSg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796116388; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=YAxAw645YJpVkroKEI198nW701gslk/Ja5+NE41jjDI=; b=xpXrE4oKaykZDptvXx1qtowj6gqjJweKOWKx6Nl0JZxph+2FpMyXMET4/MOOowzrh1Bk EtFQ6GSkMQGw/1Vty3eZ0/osUO0An2O5yz+VKN1vVsmzW6+wbqfiaEuPCFKkrBJosEXzY kI2Jz9lx5xM6nn7XuccUK60lRmO/P0473mQP06p0Rwmi2W2U5I1WbLAaTp2N5rGa+Kk01 qaFsLeBzN8lLc6DQGHSXH6085uGnISt7fqFOx17tQfVzwmf40sDm6Ms6T73N9qgA5Pyat E5ZUWx6uVGf34lg88emEscgr2EXqAuc+AlLQVloB/6b0cuMk5VB+pbDa3Uunh22Lb4A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=GRwvFuN+; arc=none smtp.remote-ip=209.85.214.175 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C5E1606A325 for ; Tue, 1 Dec 2026 09:13:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9C5E1606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=GRwvFuN+ Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2f06ff94acfso55138885ad.0 for ; Tue, 01 Dec 2026 01:13:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796116387; x=1796721187; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=YAxAw645YJpVkroKEI198nW701gslk/Ja5+NE41jjDI=; b=GRwvFuN+zNBhVcxvzn5i+NRDlx29tqVm1FYJL5IUI7o+j0804DpLJ3IBhji5UrAcp5 zKYW0DvKlCyg1sIQJS/aanmZELi8udltkS8+hh+PARuGokb9OTuxMEwua4zyUGIzJVUC 731gXlsarYm7OiKpAg6xW0L2wPyyd/CJxz5x/husZzs61CtjayykuuNBCpqDAil2N+Ql oPckE5Yn4REu4l6W/LxMU02mDxG6+3YvILNSsvtWwSqvlBHA/r6ROiyeR00hDAduejZa mK3QL1LyREGsZ6ZIkHS8T6tLLthYJZDVytZmueB+2gWabmCytqDDr5T0JcscLj2D1yfx ED5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796116387; x=1796721187; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=YAxAw645YJpVkroKEI198nW701gslk/Ja5+NE41jjDI=; b=ZwH82bcCLoZ0i+8jKGw98zWZEBRlpako6GC4T3+NdrW9+RjjmI5aHShxyhlhe8SoUX 941bIAO4J+25T31smRTg8HVhc6QmT9Db6gYaHzc6iewyH8oa4WHzLessVmhP80V/ktrf kb67sTQRZirQhdvN0mYuJNSm1G4Mqu1/vUdPr/zw9rIRHMfm2kfw/7cMmGydLrsXXOjT x3xsDDHKKyr6DYysA9x3Zb4QSfN1z9ah1VX9TMW7YZeTCwiwI8nqiydz8Y8+c5yLiPxL D4JAMQnz2x/ian5k41bX3S84i+IcaRhhn5zvMU12QzBWNWmf7ppWj2Ez65rXDpr+dT+p Jc8w== X-Forwarded-Encrypted: i=1; AL+hErGKjPPJYJs/ShqheMWZhPtajrbIiEbc9evb5MO9x+xAqkBO093mfiq7WQiraxIp2hPQXVCdC8g=@vger.kernel.org X-Gm-Message-State: APuU4Z8Fnxz40u9VVI4uDr9Y8sDQosBLHzopYJ441tSa88r8xTAVNvcW qFwC8T6fuTByQlTqEG4VVIPrw4K4Uzh/7lLFgsoZsP4sNG58tnxOTbiR X-Gm-Gg: AZFdTZfWWtGtfksgQmfwdypYFrbFog0O62Uujp/3ZXloQ8V85NNEcKngs/VGOD5UHkB P7RxbANjiFp7enuSPf5wZZwwA3bgfn3GJobOxSrf7Ok8bG4iX2axKr6Nqz++6BVzgyieWKMhXFf lPs/+wDdqI6v5xVRaIuqyltOUZAcY/F6dBZzkkpz4CAjidFazBhuJW52r2c4uKp7X98d7ZOrlG+ 6YgwzRVWY49btQD1Ej1QgwIfszPsHlSTxsab5wyYQOgyRUt1vCLMIAKTttunc0JP8E1c+yvn7wR 7vm7oZxa8LUPMAMIiFPwKHotm6Zk/lCa5fvP8e6oJDqDLX2RK19907eimgjmb9zoVnSfGbFKxfL FtjKwCvZB+BN6fpWBC6Nfa9NbQ1KgK00u+jVK4KwwL+BCprvk9diQyY/nUimn6TAxTOrryP1Xt3 Sw/h/77lnnYOZeDECDtoVUAahO2SPBM7hHawCdItZUTzzx/hSJLC1fpDRbx16YhzGG6saqTmosY 301sdoDM/GsKneQVkgAeOQ4T5wnR/iEnufBH4P4594wTBaeyrA9qGmFCqrQ09pS4BiLXsETBJjy dTiLT2M9am7MBSmW7YTK6sz/dVdq X-Received: by 2002:a17:903:181:b0:2e9:ca71:45f4 with SMTP id d9443c01a7336-2f0d8565618mr209742835ad.33.1796116386533; Tue, 01 Dec 2026 01:13:06 -0800 (PST) Received: from server227.. ([39.170.101.209]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f03f146b84sm179179325ad.71.2026.12.01.01.12.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 01:13:06 -0800 (PST) From: Zxyan Zhu To: Maxime Chevallier , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: Andrew Lunn , Jose Abreu , Maxime Coquelin , Alexandre Torgue , Sebastian Andrzej Siewior , ClarkWilliams , Steven Rostedt , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-rt-devel@lists.linux.dev, bpf@vger.kernel.org, Zxyan Zhu Subject: [PATCH net] net: stmmac: remove STMMAC_DOWN Date: Tue, 1 Dec 2026 17:12:56 +0800 Message-Id: <20261201091256.3000677-1-zxyan0222@gmail.com> X-Mailer: git-send-email 2.34.1 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Link: https://lore.kernel.org/netdev/20240327110142.159851-1-cathy.cai@unisoc.com/ Signed-off-by: Zxyan Zhu --- 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