๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27496

Re: [PATCH net-next 3/3] net: stmmac: motorcomm: mask the MSI vector during NAPI

#27496
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 20:37
216 lines
16879 bytes
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
Technical Details
Message-ID: <179650307775.3148.9488581232461008381@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378122-linux-kernel-netdev=dewy.ru
References: <20261204203130.287919-4-contact@c127.dev>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378122-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 3/3] net: stmmac: motorcomm: mask the MSI vector
 during NAPI
Date: Sat, 05 Dec 2026 20:37:57 +0000
Organization: Usenet Network
Message-ID: <179650307775.3148.9488581232461008381@kernel.org>
References: <20261204203130.287919-4-contact@c127.dev>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3115002"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:AYwHDYh0TdSAa9SP0N9hLb4kQfk= sha256:pYpDAVQVaCJ8zmVNUwZlM4GObD+0egNSkQZHlN8vtMo=
	sha1:Y0TP8XfiwbzJJuvGmUY3AYGmtK4= sha256:VVRoPUQbFRJhG4cAa3FkOjInHuGmsYCQcmRCjySGlMI=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 4C672117EAC; Sat,  5 Dec 2026 23:38:17 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.64
X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.14, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id sQ8J904pK-Ag;
	Sat,  5 Dec 2026 23:38:13 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-378122-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 8EAEA117EA8; Sat,  5 Dec 2026 23:38:04 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 335AC605F9F; Sat,  5 Dec 2026 20:38:03 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796503080;
	b=J3+l7puiXFTiqsb0U+9/2+Hn0KWDUtR/tQ7bqZxQ3w3KonEyBZa5xct1kZZUvOJdlnlc
	 WrIWxGr9qL0GiKo+0dcBYxhLm8298T0N9rAH1YaxCbjcuU6TW7iY+55SlA9zQ2pb5N6/t
	 p+CjkZmxsuuvP8h7dDjkGDFdj1GOwjU0Q5ZLKyWnf5pYya9ZClYQ2AOR9xJT0CBFDo/C0
	 QIWFR3vrRgBKfOO8cqLMpXLjKSkVlFj8vtOV8VbnNDJ5rzyjaxeLpc6KMbHtaDh/M8Pax
	 KgLHWgaellUKsFDa02/KR4NOeR4RdepK2HPoO0jj2DRl9/QcbM4dJwlwKK4PGFSH6EA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796503080;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=3x6PV8/3qJKlbiajUGUXnF+pCZXnmu6oc5ovXXQekyM=;
	b=zHQduJqyCVN/CDaPol10w+wozSWIpOd9+z1T7rHs9BNO+VFYdy/pr/7TFIlNh5kbXUTK
	 RT5nr0s4yy5RJG0vcSBKklr+z0MZ0+AogOFwGsKWs5pHbZ3T7gycm0rJ6FG1EzPlizARl
	 Tk5rQcHwPNjB/Qccmc2ALr0VaFYENIf0Am3KN9rRXFbtHrn8KImNa6PxQqyzb3SnG4qu9
	 1Hna4PUc5StH1U/11fSt6XA34kdphbZZZirWdUDuHjCbir6oifGI9wkcSepyKxzu+x8HJ
	 rkxtgEPJTu55pdHasiJwk00glCix3T3cXmv+oQqZNb3qKjquWQYnrwFqUYn0OhCrRJw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Zvndh03f;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 0FB5E606A688;
	Sat,  5 Dec 2026 20:38:00 +0000 (UTC)
X-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=Zvndh03f
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796503079;
	b=4V+SE3eiADDbzrFKbZ6l3Vh7EDaqFaPuyvHHcB9x3RX6/qDnPTQP6g+twPfQ8vBJtN1z
	 iB4ugYJOCBYSXpgFlgI155D1VyYow4vLj4ijGf/xJVdPG7iBhSXCl03fZUSLxA27Uf9FN
	 rgtOJAewSAWwb/lNAELNi5TPhvaMbZziQqbs7QKMJXirKAEelupJkYZSC8r63UglYBU3v
	 5fxkT156swyzTf2asyBw/FtgihfD0CRxbdFzWagAg306Mq30V2QOmWdX85HwoHD2xJKFP
	 U9Fjg3lN+SgIoMASEnq3SnfUaDkuaL1u8s4k9vcLW03vLbhVekBPrHoKWtAqjq2+hMQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796503079;
	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=3x6PV8/3qJKlbiajUGUXnF+pCZXnmu6oc5ovXXQekyM=;
	b=CrTxveld42Qdcb3TKzQm/22CUAdf1x00jImbRV3itlIBHPDU/QRsqo67n+13l16StmOl
	 btF4tF6ixovvl0n3jv0dFiVfpZN1PK8vkQt9a6p8X1+2+HLoGaGD8gRuWIFTv6VD9EfNI
	 UqZ3DmBUTJE4fEe9qBEyLhyYAy+XwjDOUP12iNnAMeJy7Imiv58XDY6P7IszEA2J4yWaz
	 ZOC7UH2QLmIMrZjzd2PXGIevaCTV/tOq8+J0+9OuCl/3M+e7b8+W+h18qkoLbhbNeo4vY
	 4ZL5tymuMOaMkOfdVj2ji0eAUUDpq5j3sHoWB3yRo6L9zFso7tmXgsB1+QeCDDhX3pA==
X-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=Zvndh03f;
	arc=none smtp.remote-ip=100.103.45.18
X-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 313A8606A683
	for <netdev@vger.kernel.org>; Sat,  5 Dec 2026 20:37:58 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29C101F00936;
	Sat,  5 Dec 2026 20:37:58 +0000 (UTC)
X-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==
X-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
X-In-Reply-To: <20261204203130.287919-4-contact@c127.dev>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list