Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] net: stmmac: reduce DMA interrupt latency on YT6801
@ 2026-12-04 20:31 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
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Johan Alvarado @ 2026-12-04 20:31 UTC (permalink / raw)
  To: Jakub Kicinski, Paolo Abeni, Eric Dumazet, David S . Miller,
	Andrew Lunn, Maxime Chevallier, Yao Zi
  Cc: Maxime Coquelin, Alexandre Torgue, netdev, linux-stm32,
	linux-arm-kernel, Johan Alvarado, Pengfei Zhang

On the Motorcomm YT6801 (dwmac-motorcomm), an RX or TX completion that
happens while stmmac has the DMA channel interrupt masked for NAPI does
not raise a new MSI when it is unmasked. The glue's 200 us interrupt
moderation adds to the delay. At high packet rates the RX ring
overflows. With the series, ping RTT to a peer one routed hop away
goes from 0.82-0.86 to 0.60-0.66 ms and 64-byte UDP RX loss from
0.65-1.60 % to 0.01-0.06 %, with more interrupts. Patch 3 has the full numbers.

Patch 1 stops dwmac4 from reporting TBU as TX work, as commit
305deb54c6c2 ("net: stmmac: xgmac: do not treat TBU as a TX event")
did for xgmac.

Patch 2 adds an opt-in flag to mask the per-channel MSI vector during
NAPI instead of the DMA channel interrupt, as the vendor driver does,
so the irq core resends an event raised meanwhile. Patch 3 sets it for
the YT6801 with MSI-X and turns the glue moderation off. Neither change
is enough alone.

An alternative, keeping the DMA mask and rechecking RI/TI after
unmasking, performed the same, but needed a new DMA op, an MMIO read on
every unmask and about 2000 extra acknowledges/s under UDP TX.

Only the YT6801 is known to need this. I have no other multi-MSI
dwmac4 hardware (dwmac-intel, dwmac-loongson), so only dwmac-motorcomm
sets the flag. On an affected device, bpftrace shows gaps over 2 ms
between stmmac_napi_poll_tx() calls during a 64-byte UDP TX flood.

Tested on an Orange Pi 5 Pro (RK3588S, YT6801 on PCIe 2.0 x1) with the
series backported to 7.3.6. Build tested each patch with W=1 at
net-next d5cf954cebe4.

Johan Alvarado (3):
  net: stmmac: dwmac4: do not treat TBU as a TX event
  net: stmmac: add an opt-in MSI vector mask for NAPI
  net: stmmac: motorcomm: mask the MSI vector during NAPI

 .../ethernet/stmicro/stmmac/dwmac-motorcomm.c |   8 +-
 .../net/ethernet/stmicro/stmmac/dwmac4_lib.c  |   2 -
 drivers/net/ethernet/stmicro/stmmac/stmmac.h  |   3 +
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 105 ++++++++++++++++--
 include/linux/stmmac.h                        |   1 +
 5 files changed, 106 insertions(+), 13 deletions(-)


base-commit: d5cf954cebe4f175dfd834e1dc471a3aa203ec7d
-- 
2.56.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net-next 1/3] net: stmmac: dwmac4: do not treat TBU as a TX event
  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 ` 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-04 20:31 ` [PATCH net-next 3/3] net: stmmac: motorcomm: mask the MSI vector during NAPI Johan Alvarado
  2 siblings, 1 reply; 7+ messages in thread
From: Johan Alvarado @ 2026-12-04 20:31 UTC (permalink / raw)
  To: Jakub Kicinski, Paolo Abeni, Eric Dumazet, David S . Miller,
	Andrew Lunn, Maxime Chevallier, Yao Zi
  Cc: Maxime Coquelin, Alexandre Torgue, netdev, linux-stm32,
	linux-arm-kernel, Johan Alvarado, Pengfei Zhang

Commit 1103d3a5531c ("net: stmmac: dwmac4: Also use TBU interrupt to
clean TX path") made dwmac4_dma_interrupt() report TBU as TX work.
TBUE is not in the default DMA interrupt mask and only enabled bits
are cleared, so TBU stays set on every idle TX channel.

With a shared interrupt, stmmac_dma_interrupt() checks all channels.
Every interrupt then schedules TX NAPI on every idle TX channel.

Only use TI to trigger TX processing, as commit 305deb54c6c2 ("net:
stmmac: xgmac: do not treat TBU as a TX event") did for xgmac. The
author of that commit pointed out that dwmac4 has the same problem [1].

On a YT6801 forced to a single MSI, throughput, ping and interrupt rate
did not change (5 runs each).

Link: https://lore.kernel.org/netdev/20261014045607.3421104-1-zhangfeionline@gmail.com/ [1]
Signed-off-by: Johan Alvarado <contact@c127.dev>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
index 02aa1a3dd1e2..55ca17233234 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
@@ -188,8 +188,6 @@ int dwmac4_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr,
 		ret |= handle_tx;
 	}
 
-	if (unlikely(intr_status & DMA_CHAN_STATUS_TBU))
-		ret |= handle_tx;
 	if (unlikely(intr_status & DMA_CHAN_STATUS_ERI))
 		x->rx_early_irq++;
 
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net-next 2/3] net: stmmac: add an opt-in MSI vector mask for NAPI
  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-04 20:31 ` 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
  2 siblings, 1 reply; 7+ messages in thread
From: Johan Alvarado @ 2026-12-04 20:31 UTC (permalink / raw)
  To: Jakub Kicinski, Paolo Abeni, Eric Dumazet, David S . Miller,
	Andrew Lunn, Maxime Chevallier, Yao Zi
  Cc: Maxime Coquelin, Alexandre Torgue, netdev, linux-stm32,
	linux-arm-kernel, Johan Alvarado, Pengfei Zhang

With one MSI per DMA channel, stmmac masks the channel interrupt in
DMA_CHAN_INTR_ENA during NAPI. On the YT6801, an RI or TI set while
masked raises no interrupt on unmask. The event waits for an unrelated
interrupt or the TX coalesce timer.

Add STMMAC_FLAG_NAPI_MASK_MSI_VEC. When it and STMMAC_FLAG_MULTI_MSI_EN
are set, the RX and TX MSI handlers disable their vector with
disable_irq_nosync() and the poll enables it again. The DMA channel
interrupt stays enabled, so the irq core resends events raised during
the poll on enable_irq(). The vendor driver does the same.

The channel records which vector it disabled, and a completing poll
undoes only its own mask. The TX timer and the shared interrupt keep
the DMA mask. stmmac_enable_all_dma_irq() and
stmmac_enable_rx/tx_queue() re-enable a vector left disabled by
napi_disable(). Freeing the interrupts clears the record.

The resend uses irq_retrigger() or CONFIG_HARDIRQS_SW_RESEND, which
arm64 and x86 select. Setting IRQ_DISABLE_UNLAZY instead would add two
PCIe writes per NAPI cycle.

The default is unchanged. The vector mask is untested on dwmac-intel
and dwmac-loongson.

Signed-off-by: Johan Alvarado <contact@c127.dev>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac.h  |   3 +
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 105 ++++++++++++++++--
 include/linux/stmmac.h                        |   1 +
 3 files changed, 101 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index fcc395321816..b3eb4b0d8491 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -146,6 +146,9 @@ struct stmmac_channel {
 	struct stmmac_priv *priv_data;
 	spinlock_t lock;
 	u32 index;
+	/* RX/TX MSI vector disabled for NAPI, STMMAC_FLAG_NAPI_MASK_MSI_VEC */
+	bool rx_vec_masked;
+	bool tx_vec_masked;
 };
 
 struct stmmac_fpe_cfg {
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index b3524d46863d..b34942ad08ba 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;
+		}
+		if (dir == DMA_DIR_TX && !ch->tx_vec_masked) {
+			ch->tx_vec_masked = true;
+			disable_irq_nosync(priv->msi->tx_irq[chan]);
+			return;
+		}
+	}
+
+	stmmac_disable_dma_irq(priv, priv->ioaddr, chan, dir != DMA_DIR_TX,
+			       dir != DMA_DIR_RX);
+}
+
+/* Enable the MSI vectors stmmac_napi_mask_irq() disabled for @rx/@tx and
+ * clear @rx/@tx for them. Called with ch->lock held.
+ */
+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);
+}
+
+/* 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);
+}
+
 static void stmmac_enable_all_dma_irq(struct stmmac_priv *priv)
 {
 	u8 rx_channels_count = priv->plat->rx_queues_to_use;
@@ -2604,7 +2676,7 @@ static void stmmac_enable_all_dma_irq(struct stmmac_priv *priv)
 		unsigned long flags;
 
 		spin_lock_irqsave(&ch->lock, flags);
-		stmmac_enable_dma_irq(priv, priv->ioaddr, chan, 1, 1);
+		stmmac_start_chan_irq(priv, chan, true, true);
 		spin_unlock_irqrestore(&ch->lock, flags);
 	}
 }
@@ -3179,7 +3251,11 @@ static int stmmac_napi_check(struct stmmac_priv *priv, u32 chan, u32 dir)
 	if ((status & handle_rx) && (chan < priv->plat->rx_queues_to_use)) {
 		if (napi_schedule_prep(rx_napi)) {
 			spin_lock_irqsave(&ch->lock, flags);
-			stmmac_disable_dma_irq(priv, priv->ioaddr, chan, 1, 0);
+			if (dir == DMA_DIR_RX)
+				stmmac_napi_mask_irq(priv, chan, dir);
+			else
+				stmmac_disable_dma_irq(priv, priv->ioaddr, chan,
+						       1, 0);
 			spin_unlock_irqrestore(&ch->lock, flags);
 			__napi_schedule(rx_napi);
 		}
@@ -3188,7 +3264,11 @@ static int stmmac_napi_check(struct stmmac_priv *priv, u32 chan, u32 dir)
 	if ((status & handle_tx) && (chan < priv->plat->tx_queues_to_use)) {
 		if (napi_schedule_prep(tx_napi)) {
 			spin_lock_irqsave(&ch->lock, flags);
-			stmmac_disable_dma_irq(priv, priv->ioaddr, chan, 0, 1);
+			if (dir == DMA_DIR_TX)
+				stmmac_napi_mask_irq(priv, chan, dir);
+			else
+				stmmac_disable_dma_irq(priv, priv->ioaddr, chan,
+						       0, 1);
 			spin_unlock_irqrestore(&ch->lock, flags);
 			__napi_schedule(tx_napi);
 		}
@@ -3875,6 +3955,15 @@ static void stmmac_free_irq(struct net_device *dev,
 	struct stmmac_msi *msi = priv->msi;
 	int j;
 
+	/* NAPI and the TX timers are stopped here, so no lock is needed.
+	 * With MULTI_MSI_EN the vectors are not shared, so request_irq()
+	 * sets their disable depth back to 0.
+	 */
+	for (j = 0; j < ARRAY_SIZE(priv->channel); j++) {
+		priv->channel[j].rx_vec_masked = false;
+		priv->channel[j].tx_vec_masked = false;
+	}
+
 	switch (irq_err) {
 	case REQ_IRQ_ERR_ALL:
 		irq_idx = priv->plat->tx_queues_to_use;
@@ -6217,7 +6306,7 @@ static int stmmac_napi_poll_rx(struct napi_struct *napi, int budget)
 		unsigned long flags;
 
 		spin_lock_irqsave(&ch->lock, flags);
-		stmmac_enable_dma_irq(priv, priv->ioaddr, chan, 1, 0);
+		stmmac_napi_unmask_irq(priv, chan, true, false);
 		spin_unlock_irqrestore(&ch->lock, flags);
 	}
 
@@ -6246,7 +6335,7 @@ static int stmmac_napi_poll_tx(struct napi_struct *napi, int budget)
 		unsigned long flags;
 
 		spin_lock_irqsave(&ch->lock, flags);
-		stmmac_enable_dma_irq(priv, priv->ioaddr, chan, 0, 1);
+		stmmac_napi_unmask_irq(priv, chan, false, true);
 		spin_unlock_irqrestore(&ch->lock, flags);
 	}
 
@@ -6299,7 +6388,7 @@ static int stmmac_napi_poll_rxtx(struct napi_struct *napi, int budget)
 		/* Both RX and TX work done are complete,
 		 * so enable both RX & TX IRQs.
 		 */
-		stmmac_enable_dma_irq(priv, priv->ioaddr, chan, 1, 1);
+		stmmac_napi_unmask_irq(priv, chan, true, true);
 		spin_unlock_irqrestore(&ch->lock, flags);
 	}
 
@@ -7303,7 +7392,7 @@ void stmmac_enable_rx_queue(struct stmmac_priv *priv, u32 queue)
 	stmmac_start_rx_dma(priv, queue);
 
 	spin_lock_irqsave(&ch->lock, flags);
-	stmmac_enable_dma_irq(priv, priv->ioaddr, queue, 1, 0);
+	stmmac_start_chan_irq(priv, queue, true, false);
 	spin_unlock_irqrestore(&ch->lock, flags);
 }
 
@@ -7354,7 +7443,7 @@ void stmmac_enable_tx_queue(struct stmmac_priv *priv, u32 queue)
 	stmmac_start_tx_dma(priv, queue);
 
 	spin_lock_irqsave(&ch->lock, flags);
-	stmmac_enable_dma_irq(priv, priv->ioaddr, queue, 0, 1);
+	stmmac_start_chan_irq(priv, queue, false, true);
 	spin_unlock_irqrestore(&ch->lock, flags);
 }
 
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 00be2df63d22..37e3f5c001b0 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -211,6 +211,7 @@ enum dwmac_core_type {
 #define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY	BIT(14)
 #define STMMAC_FLAG_KEEP_PREAMBLE_BEFORE_SFD	BIT(15)
 #define STMMAC_FLAG_SERDES_SUPPORTS_2500M	BIT(16)
+#define STMMAC_FLAG_NAPI_MASK_MSI_VEC		BIT(17)
 
 struct mac_device_info;
 
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net-next 3/3] net: stmmac: motorcomm: mask the MSI vector during NAPI
  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-04 20:31 ` [PATCH net-next 2/3] net: stmmac: add an opt-in MSI vector mask for NAPI Johan Alvarado
@ 2026-12-04 20:31 ` Johan Alvarado
  2026-12-05 20:37   ` netdev-bot+sashiko
  2 siblings, 1 reply; 7+ messages in thread
From: Johan Alvarado @ 2026-12-04 20:31 UTC (permalink / raw)
  To: Jakub Kicinski, Paolo Abeni, Eric Dumazet, David S . Miller,
	Andrew Lunn, Maxime Chevallier, Yao Zi
  Cc: Maxime Coquelin, Alexandre Torgue, netdev, linux-stm32,
	linux-arm-kernel, Johan Alvarado, Pengfei Zhang

On the YT6801, an RI or TI set while the DMA channel interrupt is
masked for NAPI raises no MSI on unmask. During a 64-byte UDP TX flood,
bpftrace shows over 1300 gaps longer than 2 ms between
stmmac_napi_poll_tx() calls per 10 s run.

The glue INT_MODERATION register, set to 200 us by motorcomm_init(),
adds up to 200 us of RX latency on top of RIWT (ethtool -C rx-usecs).
With rx-usecs 33, the median ping RTT is 0.32-0.36 ms with
INT_MODERATION at 0 and 0.53-0.54 ms at 200.

Set STMMAC_FLAG_NAPI_MASK_MSI_VEC under MSI-X and INT_MODERATION to 0.
The vector mask alone keeps ping RTT at 0.80-0.87 ms, and moderation 0
alone drops 64-byte UDP TX to 50.2-50.8 kpps.

Orange Pi 5 Pro (RK3588S, YT6801 on PCIe 2.0 x1), 7.3.6 backport,
default coalescing (rx-usecs 328, tx-usecs 5000, tx-frames 25), iperf3
to a peer one routed hop away, 10 s per test, 5 interleaved runs,
min-max. TX poll gaps are gaps over 2 ms traced with bpftrace.

                              before        after
  ping RTT (ms)               0.82-0.86     0.60-0.66
  TCP RX (Mb/s)               917-923       931-935
  TCP TX (Mb/s)               826-866       839-867
  UDP 64B TX (kpps)           67.3-68.1     76.9-78.7
  TX poll gaps per run        1381-1587     14-298
  UDP 64B RX loss (%)         0.65-1.60     0.01-0.06
  CPU, TCP RX (%)             10.1-12.4     11.6-13.9
  RX interrupts/s, TCP RX     1751-1776     2999-3007
  TX interrupts/s, UDP TX     884-928       7684-8492

RIWT alone now times RX interrupts, which accounts for the extra CPU.

motorcomm_resume() calls motorcomm_init(), so the setting survives
resume. Link down/up during a UDP flood left no unbalanced enable_irq()
warning.

With a single MSI only the moderation change applies:

                              before        after
  ping RTT (ms)               0.62-0.74     0.63-0.66
  UDP 64B RX loss (%)         0.68-2.20     0.01-0.03
  CPU, TCP RX (%)             9.2-13.2      13.6-14.1

TCP throughput did not change.

Signed-off-by: Johan Alvarado <contact@c127.dev>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-motorcomm.c
index 42f0b11a7b60..627cf4000dea 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);
 
 	/*
@@ -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;
 	} else {
 		dev_info(&pdev->dev, "failed to allocate MSI-X vector: %d\n",
 			 ret);
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next 1/3] net: stmmac: dwmac4: do not treat TBU as a TX event
  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
  0 siblings, 0 replies; 7+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 20:37 UTC (permalink / raw)
  To: contact
  Cc: kuba, pabeni, edumazet, davem, andrew+netdev, maxime.chevallier,
	me, mcoquelin.stm32, alexandre.torgue, netdev, linux-stm32,
	linux-arm-kernel, zhangfeionline

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit fixes a defect introduced by commit 1103d3a5531c
  ("net: stmmac: dwmac4: Also use TBU interrupt to clean TX path") and…
- [Low] Removing the stuck-TBU => handle_tx path takes away the only
  thing that, on shared-IRQ dwmac4 setups, cleaned XDP TX descriptors…

--

net: stmmac: dwmac4: do not treat TBU as a TX event

This patch stops dwmac4_dma_interrupt() from returning handle_tx when the
TBU status bit is set. TBUE is never enabled, so TBU is never cleared, and
on a shared interrupt every idle TX channel had TX NAPI scheduled. It
follows the earlier xgmac fix in commit 305deb54c6c2.

Link: https://lore.kernel.org/netdev/20261014045607.3421104-1-zhangfeionline@gmail.com/

> Commit 1103d3a5531c ("net: stmmac: dwmac4: Also use TBU interrupt to
> clean TX path") made dwmac4_dma_interrupt() report TBU as TX work.

[Severity: Low]
This isn't a bug, but should this patch have a Fixes: tag for the commit
it names?

When 1103d3a5531c was applied, DMA_CHAN_INTR_NORMAL in dwmac4_dma.h was
already:

#define DMA_CHAN_INTR_NORMAL		(DMA_CHAN_INTR_ENA_NIE | \
					 DMA_CHAN_INTR_ENA_RIE | \
					 DMA_CHAN_INTR_ENA_TIE)

So TBU has stayed set since that commit. The matching xgmac fix,
305deb54c6c2 ("net: stmmac: xgmac: do not treat TBU as a TX event"),
has Fixes: 8d07a7930434 and was merged through net.

Something like:

Fixes: 1103d3a5531c ("net: stmmac: dwmac4: Also use TBU interrupt to clean TX path")

> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
> index 02aa1a3dd1e25..55ca172332346 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
> @@ -188,8 +188,6 @@ int dwmac4_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr,
>  		ret |= handle_tx;
>  	}
>  
> -	if (unlikely(intr_status & DMA_CHAN_STATUS_TBU))
> -		ret |= handle_tx;

[Severity: Low]
With this check gone, can XDP TX descriptors go uncleaned on shared-IRQ
dwmac4 setups when the TX coalescing timer is off?

__stmmac_set_coalesce() accepts tx-usecs 0 if tx-frames is nonzero. In
that case stmmac_tx_timer_arm() returns right away:

	if (!tx_coal_timer)
		return;

stmmac_xdp_xmit_xdpf() sets IC only when the frame counter crosses a
multiple of tx_coal:

	tx_coal = READ_ONCE(priv->tx_coal_frames[queue]);
	if (tx_coal && (tx_q->tx_count_frames % tx_coal) < num_frames) {

stmmac_xmit() and the TSO path set IC when !netdev_xmit_more(). This path
has no such rule, so the last frames of an XDP_TX or ndo_xdp_xmit burst
raise no TI. Their callers, stmmac_finalize_xdp_rx() and stmmac_xdp_xmit(),
only call stmmac_tx_timer_arm(), which does nothing in this configuration.

Before this patch, TBU stayed set. Any later interrupt on the shared line
went through stmmac_dma_interrupt():

	for (chan = 0; chan < channels_to_check; chan++)
		status[chan] = stmmac_napi_check(priv, chan,
						 DMA_DIR_RXTX);

DMA_DIR_RXTX does not mask TBU, so the call returned handle_tx and
scheduled tx_napi, which cleaned those descriptors.

After this patch, only TI schedules tx_napi. For non-XSK queues, RX
interrupts only schedule rx_napi.

Would up to tx_coal_frames - 1 descriptors per queue, with their
xdp_frames and page_pool pages, then stay held until the next IC
completion on that queue?

The missing tail IC in the XDP paths predates this patch. The same
behaviour already exists with per-channel MSI, and on xgmac since
305deb54c6c2. This patch removes the fallback that hid it on shared-IRQ
dwmac4. The later patches in this series do not change the XDP IC logic
or the timer.

>  	if (unlikely(intr_status & DMA_CHAN_STATUS_ERI))
>  		x->rx_early_irq++;
>

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204203130.287919-1-contact%40c127.dev

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next 2/3] net: stmmac: add an opt-in MSI vector mask for NAPI
  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
  0 siblings, 0 replies; 7+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 20:37 UTC (permalink / raw)
  To: contact
  Cc: kuba, pabeni, edumazet, davem, andrew+netdev, maxime.chevallier,
	me, mcoquelin.stm32, alexandre.torgue, netdev, linux-stm32,
	linux-arm-kernel, zhangfeionline

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next 3/3] net: stmmac: motorcomm: mask the MSI vector during NAPI
  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
  0 siblings, 0 replies; 7+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 20:37 UTC (permalink / raw)
  To: contact
  Cc: kuba, pabeni, edumazet, davem, andrew+netdev, maxime.chevallier,
	me, mcoquelin.stm32, alexandre.torgue, netdev, linux-stm32,
	linux-arm-kernel, zhangfeionline

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-12-05 20:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox