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 87628606A322 for ; Sat, 5 Dec 2026 20:38:13 +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=cZwdiN/f; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Zvndh03f 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=3x6PV8/3qJKlbiajUGUXnF+pCZXnmu6oc5ovXXQekyM=; b=cZwdiN/fVpC1Tx+GrKNcGUlb+s PmqgDHPs0K/USJcOAUFYItA91XJwJeoYEjo9CO5wmjjGAWbYHSWa0AdOypdMXuvLA5I/l8hKbFQub OhgXfqDO8LPfLhRqs/3YK6VtiY2CJhGfAUOtnqSn5+PswBapiTydBunkoFJgZ1xgPJaA9SgKrxUm4 cuZ1F8eYUnhxFPnsIqH/ZgOQxCSaEA+HWbDyfNXju29SMIv4/IO7X06XzA7YuHNEUt6jqC/WtOiev RGg8oz4nPe6PNnwclsblA1ZpT7YaQUZgBXhhO3drP1IEBFZDbZJn/Dyf3aDGVZ6VpjTUDlKJ2meZ9 /uOTi4sw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZwWA-00000002s69-0CCe; Sat, 05 Dec 2026 20:38:02 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZwW7-00000002s5r-3Fu8 for linux-arm-kernel@lists.infradead.org; Sat, 05 Dec 2026 20:37:59 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id EA38244F12; Sat, 5 Dec 2026 20:37:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29C101F00936; Sat, 5 Dec 2026 20:37:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796503078; bh=3x6PV8/3qJKlbiajUGUXnF+pCZXnmu6oc5ovXXQekyM=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Zvndh03fXSFMFzbwf+1zZgtaCPmeed6aX0dbU0n96eObXkJbpFzd7QNADOTW9PTFZ ZO12+Km4gm1dQNl3Zs4imDPlGkHw9dlCDOarAdl5Ea8SV7TEQIh++T4KAMHkBrL9sk INcyiKq7J+KHiAl3avBI4FP8bqotpT87h+/MTPaqKhIgWQPJMQqyHjO6LJzMjVKxio 6gF41uP+KuHGrmQo7IwMB3SOsZs/6GAOWOgKvomiZ4IzmeRgY6JN0BX7efK4FLzE9G eA+rLI728d9gfHIlMgcASY5tnXzSqafwU7kZ/PVdcaiaTNV6l3UKSDjXJDglI+ac7a f1lXiCfTsC/7g== Subject: Re: [PATCH net-next 3/3] net: stmmac: motorcomm: mask the MSI vector during 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:57 +0000 Message-ID: <179650307775.3148.9488581232461008381@kernel.org> In-Reply-To: <20261204203130.287919-4-contact@c127.dev> References: <20261204203130.287919-4-contact@c127.dev> X-sashiko-severity: High 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=-11.2 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 4 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 3 · 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). - [High] net: stmmac: motorcomm: MSI vector masking drops IRQs without resend - [Medium] The YT6801 workaround leaves the TX coalesce-timer path unprotected. - [Medium] motorcomm_init() (dwmac-motorcomm.c:178-180) now writes INT_MODERATION RX/TX = 0 for every interrupt mode. - [Medium] net: stmmac: stmmac_tx_timer() leaves TIE masked with NAPI vector masking -- net: stmmac: motorcomm: mask the MSI vector during NAPI On YT6801 with MSI-X, this commit sets STMMAC_FLAG_NAPI_MASK_MSI_VEC so that NAPI masks the MSI vector instead of the DMA channel interrupt. This works around an erratum where an RI or TI latched while masked raises no MSI on unmask. It also sets the glue INT_MODERATION register to 0, so the stmmac core handles interrupt coalescing. > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c > index 42f0b11a7b606..627cf4000dea0 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c > @@ -174,8 +174,9 @@ static void motorcomm_init(struct dwmac_motorcomm_priv *priv) > { > writel(0x0, priv->base + MGMT_INT_CTRL0); > > - writel(FIELD_PREP(INT_MODERATION_RX, 200) | > - FIELD_PREP(INT_MODERATION_TX, 200), > + /* Interrupt coalescing is left to the stmmac core */ > + writel(FIELD_PREP(INT_MODERATION_RX, 0) | > + FIELD_PREP(INT_MODERATION_TX, 0), > priv->base + INT_MODERATION); [Severity: Medium] motorcomm_init() now zeroes INT_MODERATION in every interrupt mode. What happens on the single-MSI fallback in motorcomm_setup_irq()? That branch sets neither STMMAC_FLAG_MULTI_MSI_EN nor STMMAC_FLAG_NAPI_MASK_MSI_VEC. stmmac_napi_mask_irq() only switches to vector masking when both flags are set: stmmac_napi_mask_irq() { if ((priv->plat->flags & STMMAC_FLAG_NAPI_MASK_MSI_VEC) && (priv->plat->flags & STMMAC_FLAG_MULTI_MSI_EN)) { ... stmmac_disable_dma_irq(priv, priv->ioaddr, chan, dir != DMA_DIR_TX, dir != DMA_DIR_RX); } So single MSI still uses the DMA channel mask/unmask that the commit message says loses RI/TI. It now also loses the 200 us glue moderation. On MSI-X, the commit message reports that moderation 0 without the vector mask "drops 64-byte UDP TX to 50.2-50.8 kpps". The single-MSI table lists ping RTT, UDP RX loss and CPU. It does not list 64-byte UDP TX pps or TX poll gaps. Can small-packet TX regress on single-MSI systems? Probe calls motorcomm_setup_irq() before motorcomm_init(). Could the moderation value depend on the interrupt mode that was obtained? It could be stored in dwmac_motorcomm_priv so that motorcomm_resume() programs the same value. [ ... ] > @@ -272,7 +273,8 @@ static int motorcomm_setup_irq(struct pci_dev *pdev, > res->tx_irq[0] = pci_irq_vector(pdev, 4); > res->irq = pci_irq_vector(pdev, 5); > > - plat->flags |= STMMAC_FLAG_MULTI_MSI_EN; > + plat->flags |= STMMAC_FLAG_MULTI_MSI_EN | > + STMMAC_FLAG_NAPI_MASK_MSI_VEC; [Severity: High] Does the vector mask depend on the IRQ core replaying an interrupt that arrives while the vector is disabled? stmmac_napi_mask_irq() leaves RIE/TIE enabled and uses disable_irq_nosync(), which is a lazy disable. Suppose the DMA raises an MSI while NAPI is polling. handle_edge_irq() sees the descriptor disabled, sets IRQS_PENDING, masks the vector and returns. It never calls stmmac_msi_intr_rx() or stmmac_msi_intr_tx(), so RI/TI stay latched in the channel status register. When the poll finishes, enable_irq() ends up in check_irq_resend(). That clears IRQS_PENDING, then tries try_retrigger() and then irq_sw_resend(). If the irqchip has no irq_retrigger callback and the architecture does not select HARDIRQS_SW_RESEND, irq_sw_resend() returns -EINVAL. The interrupt is then silently dropped. LoongArch looks like such a case. arch/loongarch/Kconfig does not select HARDIRQS_SW_RESEND. The Loongson MSI chain (pch-msi, avec, eiointc, htvec) does not implement irq_retrigger either. YT6801 cards are common on LoongArch machines, and DWMAC_MOTORCOMM only depends on PCI. The arm64 RK3588 setup in the commit message presumably gets a resend, which would explain why testing did not hit this. In that case RI/TI are never cleared. Given the erratum in the commit message, the device may not raise another MSI while they stay set. RX could then stall until the interface is reset. TX would only be reaped when the txtimer fires, or never if tx-usecs is 0. Should STMMAC_FLAG_NAPI_MASK_MSI_VEC only be set when a resend is guaranteed, e.g. gated on IS_ENABLED(CONFIG_HARDIRQS_SW_RESEND)? Alternatively, the vectors could be marked IRQ_DISABLE_UNLAZY. Then the MSI-X entry is masked up front, and the event is held in the MSI-X pending bit, if the YT6801 implements that correctly. [Severity: Medium] This is related to the stmmac_tx_timer() comment above, but the outcome is worse. Can TIE end up cleared for good once the vector mask is in use? Take tx_napi with napi_defer_hard_irqs and gro_flush_timeout set by the administrator: A TX MSI runs stmmac_msi_intr_tx(). stmmac_napi_mask_irq() sets ch->tx_vec_masked and calls disable_irq_nosync() on the TX vector. DMA_CHAN_INTR_ENA_TIE stays set. stmmac_napi_poll_tx() cleans some frames. napi_complete_done() then defers: it clears NAPI_STATE_SCHED, arms the NAPI timer and returns false. So stmmac_napi_unmask_irq() is skipped and ch->tx_vec_masked stays true. NAPI is no longer scheduled, so stmmac_tx_timer_arm() arms tx_q->txtimer. This happens from the poll when pending_packets is set, or from stmmac_xmit(). If the txtimer fires first, stmmac_tx_timer() wins napi_schedule_prep(). It calls stmmac_disable_dma_irq(priv, priv->ioaddr, ch->index, 0, 1), which clears TIE while the vector is still masked. When napi_complete_done() finally returns true, stmmac_napi_unmask_irq() calls stmmac_napi_unmask_vec(). That sees ch->tx_vec_masked, calls enable_irq() and clears *tx. So stmmac_enable_dma_irq() is never called for TX, and TIE stays cleared in hardware. >>From then on, TX completions are only reaped by the txtimer, which defaults to 5 ms. If tx-usecs is later set to 0 with ethtool -C, nothing schedules TX NAPI again. The queue then fills until stmmac_tx_timeout() resets the device. The flag and helpers come from the previous patch. This is their first user, though, so this is where the path becomes reachable. Would it be safer for stmmac_napi_unmask_vec() to leave *tx set, so that TIE is always re-enabled? Or should stmmac_tx_timer() skip the DMA mask when ch->tx_vec_masked is already set? [Severity: Medium] Does this cover every NAPI scheduler that masks the DMA channel interrupt? stmmac_tx_timer() still schedules tx_napi by clearing TIE at the DMA level: drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:stmmac_tx_timer() { ... if (likely(napi_schedule_prep(napi))) { ... stmmac_disable_dma_irq(priv, priv->ioaddr, ch->index, 0, 1); ... __napi_schedule(napi); } ... } When that poll completes, stmmac_napi_poll_tx() calls stmmac_napi_unmask_irq(). There tx_vec_masked is false, so stmmac_napi_unmask_vec() leaves tx set and TIE is re-enabled at the DMA level: stmmac_napi_unmask_irq() { stmmac_napi_unmask_vec(priv, chan, &rx, &tx); if (rx || tx) stmmac_enable_dma_irq(priv, priv->ioaddr, chan, rx, tx); } According to the commit message, a TI latched during that poll raises no MSI on this unmask. The completion is then picked up only when the TX hrtimer fires again (tx-usecs, 5000 us by default) or when a later TX MSI arrives. This path runs often during a TX flood. stmmac_napi_poll_tx() re-arms the timer whenever pending_packets is set, and stmmac_xmit() also arms it. Could this account for the remaining "TX poll gaps per run ... 14-298" in the after column? The preceding commit, "net: stmmac: add an opt-in MSI vector mask for NAPI", says "The TX timer and the shared interrupt keep the DMA mask". With MULTI_MSI_EN and NAPI_MASK_MSI_VEC both set, could stmmac_tx_timer() call stmmac_napi_mask_irq(priv, chan, DMA_DIR_TX) instead? disable_irq_nosync() can be called from hrtimer context. > } else { > dev_info(&pdev->dev, "failed to allocate MSI-X vector: %d\n", > ret); -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204203130.287919-1-contact%40c127.dev