From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796503077; b=YKWgptjNvDspNZcI53/EzW30Bv1d3ZZpoeqAgLVuXxWLFCSXv/2zntqfZ8HyVBxv3B39 yW53E3JME5b6koEt2fgtFJyNICIZuoInmUNLJW+ji/QY9UfHytRmGfz1HC9YkF13cEQpm +etWMoiLlR/3puXgqGw/LxmSQ2ybgyIGT4FurUnsFN3Muljt4d4lhcDdcVdKxBGsFhfRP 0EpAwYTg4HofpLRqOqoI4ukUGUznNpTxaLb31/+pVEwrWFGZzJBf1EBidMFx+14d3NQcV ZmlqvsGZ4XV7C180WAycLeS0f4IkYNFmQx4XvFX8cPw2GfTP1GtEkcGmm0biPXOobLA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796503077; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=flZTXOs/hA1kbbWai6MvrK2YQD5ehrLRl0tSH6D5U5w=; b=oC4w1+O7G2ahfOwEuDai/mwax7bUgL8W/sUVjLYaQYe4ftL/caYCckkaFnzuP7wR8WRx lAg82s4C6NbMhN5j9S5ARgg0mCnqlJKyOzrNclWdF7S//JFktZosT+6+yLHJQhkkqyMZr SuPuVIY0fjT0Xsogp/mxjI2+NJhKsWrbTnx8v5nWJS9izFc1RdrEDKO5lKUyfqPm1mBFV Fbj1fibY4MH4L0GS7XMO9NEOpbVsdfYjAVN5zbRwlAds7WWBX5F64OKNh6pt4Llz4pUt3 6R37yyGBNYxgIwjOkP40UfKRA/zQYh7yDOxyhkyE+/ssqyWv9tqR478XaoZ3AKZmtbQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QQRwkkAv; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9F5B606A335 for ; Sat, 5 Dec 2026 20:37:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QQRwkkAv Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEDD91F0092B; Sat, 5 Dec 2026 20:37:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796503077; bh=flZTXOs/hA1kbbWai6MvrK2YQD5ehrLRl0tSH6D5U5w=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=QQRwkkAvFHeNFS2YtHMMk0tUN/345fuowsj2t9rbu8T4aqhNq3cgttYK3N3tcVIVw Rgmg2Ns+d/tYQ2iprmVXheX9B60CYevtBHw2EZ8TUM6Jxq+9iaxB8BCgLaIdm6YZc9 106S0JY22vj8AxkV8aZUJWhN6MxaGEIIrDJtejQZi/fc2y/xyMOYDLGd09lc0hA37z g+EilQXqr2apOCl6q6YKT2WpLGPD5z0Jsj8krWFNjlyCZfPXXfLE55H/DlPFMcGZcG TnezSQwezxectJZsrWczLKt51wYw5YhLzPFZ7ZZcH5W8cBTTZqIKV3vI3NO8aGrKid LVfbDpyxOTgYQ== Subject: Re: [PATCH net-next 2/3] net: stmmac: add an opt-in MSI vector mask for NAPI From: netdev-bot+sashiko@kernel.org To: contact@c127.dev Cc: kuba@kernel.org, pabeni@redhat.com, edumazet@kernel.org, davem@davemloft.net, andrew+netdev@lunn.ch, maxime.chevallier@bootlin.com, me@ziyao.cc, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, zhangfeionline@gmail.com Date: Sat, 05 Dec 2026 20:37:56 +0000 Message-ID: <179650307649.3148.17022466268731706828@kernel.org> In-Reply-To: <20261204203130.287919-3-contact@c127.dev> References: <20261204203130.287919-3-contact@c127.dev> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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 Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider. Critical: 0 · High: 0 (1) · Medium: 2 · 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] stmmac_napi_unmask_irq() (stmmac_main.c:2647-2653) calls stmmac_napi_unmask_vec() first. - [Medium] The vector mask depends on the irq core replaying the event that arrives while the vector is lazily disabled. Pre-existing issues: - [High] In stmmac_setup_tc_block_cb() (drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:6743-6767), NAPI is… -- net: stmmac: add an opt-in MSI vector mask for NAPI This patch adds STMMAC_FLAG_NAPI_MASK_MSI_VEC. When it is set together with STMMAC_FLAG_MULTI_MSI_EN, the per-channel RX/TX MSI handlers mask their vector with disable_irq_nosync() instead of masking the channel interrupt in DMA_CHAN_INTR_ENA. The NAPI poll re-enables the vector, and the irq core is expected to resend any event raised while it was masked. > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index b3524d46863da..b34942ad08ba0 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -2592,6 +2592,78 @@ static void stmmac_stop_tx_dma(struct stmmac_priv *priv, u32 chan) > stmmac_stop_tx(priv, priv->ioaddr, chan); > } > > +/* Mask a channel interrupt for NAPI. With STMMAC_FLAG_NAPI_MASK_MSI_VEC > + * and per-channel MSIs, the MSI vector is disabled instead of the DMA > + * channel interrupt, so an event raised meanwhile is resent by the irq > + * core (lazy disable) when the vector is enabled again. Called with > + * ch->lock held. > + */ > +static void stmmac_napi_mask_irq(struct stmmac_priv *priv, u32 chan, > + u32 dir) > +{ > + struct stmmac_channel *ch = &priv->channel[chan]; > + > + if ((priv->plat->flags & STMMAC_FLAG_NAPI_MASK_MSI_VEC) && > + (priv->plat->flags & STMMAC_FLAG_MULTI_MSI_EN)) { > + if (dir == DMA_DIR_RX && !ch->rx_vec_masked) { > + ch->rx_vec_masked = true; > + disable_irq_nosync(priv->msi->rx_irq[chan]); > + return; > + } [Severity: Medium] What happens here on architectures that provide neither irq_retrigger nor CONFIG_HARDIRQS_SW_RESEND? The PCI MSI/MSI-X chips have no irq_disable callback, so disable_irq_nosync() is a lazy disable. An MSI that arrives while the vector is disabled sets IRQS_PENDING. On enable_irq(), check_irq_resend() clears IRQS_PENDING and then does: if (!try_retrigger(desc)) err = irq_sw_resend(desc); Without CONFIG_HARDIRQS_SW_RESEND, irq_sw_resend() is a stub that returns -EINVAL. LoongArch, for example, does not select HARDIRQS_SW_RESEND, and none of the Loongson irqchips (pch-msi, eiointc, avec) implement irq_retrigger. DWMAC_MOTORCOMM depends only on PCI. The later motorcomm patch in this series sets the flag unconditionally on MSI-X in motorcomm_setup_irq(): plat->flags |= STMMAC_FLAG_MULTI_MSI_EN | STMMAC_FLAG_NAPI_MASK_MSI_VEC; On such a host, could an RI/TI raised between the poll's last descriptor check and enable_irq() be dropped? The stmmac handler would never run for it, so the latched DMA_CHAN_STATUS bit would wait for an unrelated event. That is the same symptom this patch is meant to fix. The commit message says: The resend uses irq_retrigger() or CONFIG_HARDIRQS_SW_RESEND, which arm64 and x86 select. The code does not enforce this dependency, though. Should the flag be gated (for example with IS_ENABLED(CONFIG_HARDIRQS_SW_RESEND))? Other options would be to fall back to IRQ_DISABLE_UNLAZY, or to re-check the channel status after enable_irq(). > + if (dir == DMA_DIR_TX && !ch->tx_vec_masked) { > + ch->tx_vec_masked = true; > + disable_irq_nosync(priv->msi->tx_irq[chan]); > + return; > + } > + } [ ... ] > +static void stmmac_napi_unmask_vec(struct stmmac_priv *priv, u32 chan, > + bool *rx, bool *tx) > +{ > + struct stmmac_channel *ch = &priv->channel[chan]; > + > + if (*rx && ch->rx_vec_masked) { > + ch->rx_vec_masked = false; > + enable_irq(priv->msi->rx_irq[chan]); > + *rx = false; > + } > + if (*tx && ch->tx_vec_masked) { > + ch->tx_vec_masked = false; > + enable_irq(priv->msi->tx_irq[chan]); > + *tx = false; > + } > +} > + > +/* Undo stmmac_napi_mask_irq() or a DMA mask from the other NAPI > + * schedulers when a poll completes. Called with ch->lock held. > + */ > +static void stmmac_napi_unmask_irq(struct stmmac_priv *priv, u32 chan, > + bool rx, bool tx) > +{ > + stmmac_napi_unmask_vec(priv, chan, &rx, &tx); > + if (rx || tx) > + stmmac_enable_dma_irq(priv, priv->ioaddr, chan, rx, tx); > +} [Severity: Medium] Can a completing TX poll leave DMA_CHAN_INTR_ENA.TIE cleared here? stmmac_napi_unmask_vec() clears *tx whenever ch->tx_vec_masked is set, so stmmac_enable_dma_irq() is skipped for TX. That assumes only one TX mask is outstanding. However, stmmac_tx_timer() still applies the DMA mask without checking tx_vec_masked: if (likely(napi_schedule_prep(napi))) { ... stmmac_disable_dma_irq(priv, priv->ioaddr, ch->index, 0, 1); One possible sequence: 1. A TX MSI goes through stmmac_napi_check(dir=DMA_DIR_TX), and stmmac_napi_mask_irq() sets tx_vec_masked and calls disable_irq_nosync(tx_irq). 2. The poll finishes, but napi_complete_done() returns false while still clearing NAPIF_STATE_SCHED. This happens with napi_defer_hard_irqs plus gro_flush_timeout, or with prefer-busy-poll. stmmac_napi_poll_tx() skips the unmask, so tx_vec_masked stays true. 3. stmmac_tx_timer_arm() arms txtimer, because napi_is_scheduled() is now false. 4. stmmac_tx_timer() wins napi_schedule_prep() and clears TIE. 5. When that poll completes, stmmac_napi_unmask_irq(priv, chan, false, true) calls only enable_irq(), and TIE stays cleared. After this, would TX completions stop raising an MSI until a later timer-driven poll completes with tx_vec_masked == false? That is the timer-only TX completion behaviour this patch is trying to remove. Before the patch, both masks were the same DMA bit, so this state could not occur. > + > +/* Enable the channel interrupts when a queue (re)starts. A NAPI stopped > + * by napi_disable() may have left its vector disabled. > + */ > +static void stmmac_start_chan_irq(struct stmmac_priv *priv, u32 chan, > + bool rx, bool tx) > +{ > + bool vrx = rx, vtx = tx; > + > + stmmac_napi_unmask_vec(priv, chan, &vrx, &vtx); > + stmmac_enable_dma_irq(priv, priv->ioaddr, chan, rx, tx); > +} [Severity: High] This is a pre-existing issue, but is there a napi_disable()/napi_enable() path that never reaches stmmac_start_chan_irq()? stmmac_setup_tc_block_cb() does: __stmmac_disable_all_queues(priv); ... stmmac_enable_all_queues(priv); Those helpers only call napi_disable() and napi_enable(). Consider this sequence on an RX channel: RX MSI hardirq stmmac_napi_check(dir=DMA_DIR_RX) napi_schedule_prep(rx_napi) stmmac_napi_mask_irq() ch->rx_vec_masked = true; disable_irq_nosync(priv->msi->rx_irq[chan]); tc filter add/delete with hw offload stmmac_setup_tc_block_cb() __stmmac_disable_all_queues() napi_disable() Under load, stmmac_napi_poll_rx() returns the full budget. The napi_complete_done() branch that calls stmmac_napi_unmask_irq() is skipped, and __napi_poll() completes NAPI itself: if (unlikely(napi_disable_pending(n))) { napi_complete(n); return work; } stmmac_enable_all_queues() then calls napi_enable(), but nothing calls enable_irq(). Would the RX vector stay at disable depth 1 with rx_vec_masked still true? RX has no timer fallback. Would rx_napi on that channel then never be scheduled again until close/open or resume? The commit message says: stmmac_enable_all_dma_irq() and stmmac_enable_rx/tx_queue() re-enable a vector left disabled by napi_disable(). This path goes through neither of them. The old DMA mask scheme leaves DMA_CHAN_INTR_ENA.RIE cleared on this path in the same way, so the stall predates this patch. However, the later YT6801 glue patch in this series ("net: stmmac: motorcomm: mask the MSI vector during NAPI") wires only rx_irq[0]. There, this would stop RX for the whole interface. On TX, a later timer-driven poll undoes the stale tx_vec_masked left here. Because of the mask stacking described above in stmmac_napi_unmask_irq(), that leaves TIE masked for one more timer cycle. [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204203130.287919-1-contact%40c127.dev