From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 021E7606A68E for ; Thu, 3 Dec 2026 09:16:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=iRrPLg3m; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IWroeZut DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:Message-ID:Date :Cc:To:From:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=P5Ep9htVu4cJXTRDVnqRDWWE0NfdQwPiihvyOHvQ55A=; b=iRrPLg3mk0Gz0Xv0b4om/aWa7J FPxGbXTkeZjTBX7eqmPrAS7dbjh8zL9p7AcI5uY7Eu+M5Uo08XlUTHBt/qEfAkia7I4CGqL22Juov 7qfLZfMng+5OzDgg/ukgcyxrN/Pp+ymA6Too+xNmMWKZZ0aQohXUtyCi0mzxtb6prdJj6FWOxLxRd QiKlihbMv6jmdXCOGM8dXHmechq/r3sXOz7YHA9jENPPNr0vGnZiGgTvTMxesxiRq1Effe7lVP9jB JQtqZiRmG7YgdrHu1Ej5cy8G/Qt8FhNw8Xo2uWp+FwiocE33q/BRA6qZPk7NMF71nrXVGTRub5JcX /yIdT5ZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ2v9-0000000Dxj8-47eP; Thu, 03 Dec 2026 09:16:07 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ2v0-0000000Dxhu-1ghb for linux-arm-kernel@lists.infradead.org; Thu, 03 Dec 2026 09:16:02 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 9A1E76142A; Thu, 3 Dec 2026 09:15:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DE891F0089C; Thu, 3 Dec 2026 09:15:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796289357; bh=P5Ep9htVu4cJXTRDVnqRDWWE0NfdQwPiihvyOHvQ55A=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=IWroeZutzS/fV3knKbvsdgKzOcvbxKskvMEYWH4KoP/DDYm8mKIMCB6pn63F84j1G cHRtIbtDiyBNDXT6rZZBLcdTVznI/MryZ+E953YeZbblIzV1ruaVYhY0dMYFHOGcbn jm5uzYtmsn2nMzvelr0gfB+QsGnSGsp+Xu3cdvxn8GFLTJVjr3NuDqfye8Qv/KU/oU TdnVffjEfUzZR8jw50d8C60ZBh3F2Yk7uSUtl0fH9j+1FoTIXr/cP8mzFUWFy/Go4B u7R/226tQgJGPNr3bO4kjFb9xAMXbWqNaYrNOvuT5tIYr8hU/87l/rMhPb/Zt++2I6 al6N9s7Kdqpmg== Subject: Re: [PATCH net] net: stmmac: remove STMMAC_DOWN From: netdev-bot+sashiko@kernel.org To: zxyan0222@gmail.com Cc: maxime.chevallier@bootlin.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, andrew+netdev@lunn.ch, Jose.Abreu@synopsys.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, bigeasy@linutronix.de, clrkwllms@kernel.org, rostedt@goodmis.org, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, 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 Date: Thu, 03 Dec 2026 09:15:55 +0000 Message-ID: <179628935561.3146.10251855086500360375@kernel.org> In-Reply-To: <20261201091256.3000677-1-zxyan0222@gmail.com> References: <20261201091256.3000677-1-zxyan0222@gmail.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Archived-By: MIME-Version: 1.0 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 (1) · Medium: 1 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] A fatal error raised during the reset window can now be consumed and its reset request silently dropped. Pre-existing issues: - [High] This problem wasn't introduced by this patch, but it can cause a hang or use-after-free on driver removal. -- net: stmmac: remove STMMAC_DOWN This patch removes the STMMAC_DOWN state bit. That bit was only ever set inside stmmac_reset_subtask(), around dev_close()/dev_open(). The interrupt handlers no longer return early during the reset window, and stmmac_xdp_xmit() and stmmac_xsk_wakeup() test STMMAC_RESETING instead. Link: https://lore.kernel.org/netdev/20240327110142.159851-1-cathy.cai@unisoc.com/ > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index a685ce4638f61..7f7be965604e0 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); > } [Severity: Medium] Can a reset request raised during the reset window get lost here? The commit message says stmmac_service_event_schedule() is "already guarded by STMMAC_SERVICE_SCHED". However, that bit stays set for the whole reset, because stmmac_service_task() clears it only after stmmac_reset_subtask() returns: stmmac_service_task() { stmmac_reset_subtask(priv); clear_bit(STMMAC_SERVICE_SCHED, &priv->state); } With the STMMAC_DOWN early returns gone, stmmac_interrupt(), stmmac_safety_interrupt() and (on GMAC4) stmmac_mac_interrupt() -> stmmac_dma_err_interrupt() now run normally during that window. In the dev_open() half, __stmmac_open() re-arms the safety features in stmmac_hw_setup(). It then calls phylink_start() and stmmac_request_irq() before dev_open() returns. If an uncorrectable safety error or fatal DMA error fires after the IRQs are requested, the handler consumes it. On XGMAC, dwxgmac3_handle_mac_err() writes the status back to clear it, and then: stmmac_safety_feat_interrupt() stmmac_global_err() netif_carrier_off(priv->dev); set_bit(STMMAC_RESET_REQUESTED, &priv->state); stmmac_service_event_schedule() test_and_set_bit(STMMAC_SERVICE_SCHED) returns 1, no queue_work() stmmac_reset_subtask() already consumed STMMAC_RESET_REQUESTED with test_and_clear_bit() before dev_close(), and nothing checks it again afterwards. The hardware status has been cleared, so the IRQ doesn't fire again. Wouldn't this leave the MAC running after an uncorrectable fault with no reset pending? If phylink had already resolved link-up, carrier also stays off. dev_watchdog() doesn't call ndo_tx_timeout while carrier is off. That means nothing seems to re-queue the service task until a link event or an admin down/up. A narrower form of this race existed before, between clear_bit(STMMAC_DOWN) and clear_bit(STMMAC_SERVICE_SCHED). Before this patch, though, the handlers did not touch latched errors during the rest of the reset window. Would it help to clear STMMAC_SERVICE_SCHED before calling stmmac_reset_subtask()? Alternatively, the service task could check STMMAC_RESET_REQUESTED again after clearing STMMAC_SERVICE_SCHED, and requeue the work if it is set. [ ... ] > @@ -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(); > } [Severity: High] This isn't a bug introduced by this patch, but can this dev_open() run on a netdev that is being unregistered? stmmac_dvr_remove() doesn't cancel priv->service_task before teardown: stmmac_dvr_remove() { ... unregister_netdev(ndev); ... phylink_destroy(priv->phylink); ... stmmac_mdio_unregister(ndev); destroy_workqueue(priv->wq); ... } stmmac_global_err() can queue the work in two ways: - from an IRQ handler, before free_irq() runs in the unregister close path - from ndo_tx_timeout, just before unregister_netdev() The worker then blocks in rtnl_lock() here. Once unregister_netdev() drops RTNL in netdev_run_todo(), the worker continues. Its dev_close() does nothing because IFF_UP is clear, and dev_open() reaches __dev_open(). __dev_open() only checks netif_device_present(), and unregister doesn't clear __LINK_STATE_PRESENT. So stmmac_open() runs: it connects the PHY, requests IRQs and allocates DMA rings, and dev_activate() attaches qdiscs that hold netdev references. Depending on timing, couldn't this make netdev_wait_allrefs_any() wait forever? Or could stmmac_dvr_remove() go on to phylink_destroy() and stmmac_mdio_unregister() while the worker is still using priv->phylink? destroy_workqueue() only drains the work after those calls. The STMMAC_DOWN check removed above never covered this, since the bit was only set inside this same function. Is a cancel_work_sync() on priv->service_task needed before unregister_netdev()? Some other check that stops the reset once the device is going away would also work. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201091256.3000677-1-zxyan0222%40gmail.com