Skip to contentSkip to conversation

net: xilinx: axienet: Schedule NAPI in two steps

PATCH Applied Sean Anderson 3 participants 3 messages Sep 13, 2024 – Sep 19, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: xilinx: axienet: Schedule NAPI in two steps

As advised by Documentation/networking/napi.rst, masking IRQs after calling napi_schedule can be racy. Avoid this by only masking/scheduling if napi_schedule_prep returns true.

Fixes 9e2bc267e780 ("net: axienet: Use NAPI for TX completion path")
Fixes cc37610caaf8 ("net: axienet: implement NAPI and GRO receive")

---

Changes in v2:
- Don't use the irqoff variant of __napi_schedule

 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +8 -6
index 9eb300fc3590..3de6559ceea6 100644
@@ -1222,9 +1222,10 @@ static irqreturn_t axienet_tx_irq(int irq, void *_ndev)
 		u32 cr = lp->tx_dma_cr;
 
 		cr &= ~(XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK);
-		axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr);
-
-		napi_schedule(&lp->napi_tx);
+		if (napi_schedule_prep(&lp->napi_tx)) {
+			axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr);
+			__napi_schedule(&lp->napi_tx);
+		}
 	}
 
 	return IRQ_HANDLED;
@@ -1266,9 +1267,10 @@ static irqreturn_t axienet_rx_irq(int irq, void *_ndev)
 		u32 cr = lp->rx_dma_cr;
 
 		cr &= ~(XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK);
-		axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr);
-
-		napi_schedule(&lp->napi_rx);
+		if (napi_schedule_prep(&lp->napi_rx)) {
+			axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr);
+			__napi_schedule(&lp->napi_rx);
+		}
 	}
 
 	return IRQ_HANDLED;
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines · Sean Anderson

As advised by Documentation/networking/napi.rst, masking IRQs after calling napi_schedule can be racy. Avoid this by only masking/scheduling if napi_schedule_prep returns true.

Fixes 9e2bc267e780 ("net: axienet: Use NAPI for TX completion path")
Fixes cc37610caaf8 ("net: axienet: implement NAPI and GRO receive")

---

#2 lore raw
In reply to Sean Anderson
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

Quoted 10 lines · On Fri, 13 Sep 2024 10:57:11 -0400 you wrote:

As advised by Documentation/networking/napi.rst, masking IRQs after calling napi_schedule can be racy. Avoid this by only masking/scheduling if napi_schedule_prep returns true.

Fixes 9e2bc267e780 ("net: axienet: Use NAPI for TX completion path")
Fixes cc37610caaf8 ("net: axienet: implement NAPI and GRO receive")

[...]

Here is the summary with links:
- [net,v2] net: xilinx: axienet: Schedule NAPI in two steps

    https://git.kernel.org/netdev/net/c/ba0da2dc934e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html