Netdev List
 help / color / mirror / Atom feed
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
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	[thread overview]
Message-ID: <179650307775.3148.9488581232461008381@kernel.org> (raw)
In-Reply-To: <20261204203130.287919-4-contact@c127.dev>

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

      reply	other threads:[~2026-12-05 20:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 20:31 [PATCH net-next 0/3] net: stmmac: reduce DMA interrupt latency on YT6801 Johan Alvarado
2026-12-04 20:31 ` [PATCH net-next 1/3] net: stmmac: dwmac4: do not treat TBU as a TX event Johan Alvarado
2026-12-05 20:37   ` netdev-bot+sashiko
2026-12-04 20:31 ` [PATCH net-next 2/3] net: stmmac: add an opt-in MSI vector mask for NAPI Johan Alvarado
2026-12-05 20:37   ` netdev-bot+sashiko
2026-12-04 20:31 ` [PATCH net-next 3/3] net: stmmac: motorcomm: mask the MSI vector during NAPI Johan Alvarado
2026-12-05 20:37   ` netdev-bot+sashiko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179650307775.3148.9488581232461008381@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=contact@c127.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=maxime.chevallier@bootlin.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=me@ziyao.cc \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=zhangfeionline@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox