netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/2] amd-xgbe: schedule NAPI on RBU event
@ 2025-11-29 17:50 Raju Rangoju
  2025-11-29 17:50 ` [PATCH net-next v2 1/2] amd-xgbe: refactor the dma IRQ handling code path Raju Rangoju
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Raju Rangoju @ 2025-11-29 17:50 UTC (permalink / raw)
  To: netdev
  Cc: pabeni, kuba, edumazet, davem, andrew+netdev, Shyam-sundar.S-k,
	Raju Rangoju

During the RX overload the Rx buffers may not be refilled, trying to
schedule the NAPI when an Rx Buffer Unavailable is signaled may help in
improving the such situation, in case we missed an IRQ.

Raju Rangoju (2):
  amd-xgbe: refactor the dma IRQ handling code path
  amd-xgbe: schedule NAPI on Rx Buffer Unavailable (RBU)

 drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 71 +++++++++++++++++-------
 1 file changed, 51 insertions(+), 20 deletions(-)

-- 
2.34.1


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

* [PATCH net-next v2 1/2] amd-xgbe: refactor the dma IRQ handling code path
  2025-11-29 17:50 [PATCH net-next v2 0/2] amd-xgbe: schedule NAPI on RBU event Raju Rangoju
@ 2025-11-29 17:50 ` Raju Rangoju
  2025-11-29 17:50 ` [PATCH net-next v2 2/2] amd-xgbe: schedule NAPI on Rx Buffer Unavailable (RBU) Raju Rangoju
  2025-12-01 22:50 ` [PATCH net-next v2 0/2] amd-xgbe: schedule NAPI on RBU event patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Raju Rangoju @ 2025-11-29 17:50 UTC (permalink / raw)
  To: netdev
  Cc: pabeni, kuba, edumazet, davem, andrew+netdev, Shyam-sundar.S-k,
	Raju Rangoju

Refactor the DMA interrupt bottom-half handling to improve the
readability, maintainability, without changing the intended behavior.

Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com>
---
 drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 60 ++++++++++++++++--------
 1 file changed, 40 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index 0653e69f0ef7..aca1c57554d7 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -367,10 +367,11 @@ static irqreturn_t xgbe_ecc_isr(int irq, void *data)
 static void xgbe_isr_bh_work(struct work_struct *work)
 {
 	struct xgbe_prv_data *pdata = from_work(pdata, work, dev_bh_work);
+	unsigned int mac_isr, mac_tssr, mac_mdioisr;
 	struct xgbe_hw_if *hw_if = &pdata->hw_if;
-	struct xgbe_channel *channel;
+	bool per_ch_irq, ti, ri, rbu, fbe;
 	unsigned int dma_isr, dma_ch_isr;
-	unsigned int mac_isr, mac_tssr, mac_mdioisr;
+	struct xgbe_channel *channel;
 	unsigned int i;
 
 	/* The DMA interrupt status register also reports MAC and MTL
@@ -384,43 +385,62 @@ static void xgbe_isr_bh_work(struct work_struct *work)
 	netif_dbg(pdata, intr, pdata->netdev, "DMA_ISR=%#010x\n", dma_isr);
 
 	for (i = 0; i < pdata->channel_count; i++) {
+		bool schedule_napi = false;
+		struct napi_struct *napi;
+
 		if (!(dma_isr & (1 << i)))
 			continue;
 
 		channel = pdata->channel[i];
 
 		dma_ch_isr = XGMAC_DMA_IOREAD(channel, DMA_CH_SR);
+
+		/* Precompute flags once */
+		ti  = !!XGMAC_GET_BITS(dma_ch_isr, DMA_CH_SR, TI);
+		ri  = !!XGMAC_GET_BITS(dma_ch_isr, DMA_CH_SR, RI);
+		rbu = !!XGMAC_GET_BITS(dma_ch_isr, DMA_CH_SR, RBU);
+		fbe = !!XGMAC_GET_BITS(dma_ch_isr, DMA_CH_SR, FBE);
+
 		netif_dbg(pdata, intr, pdata->netdev, "DMA_CH%u_ISR=%#010x\n",
 			  i, dma_ch_isr);
 
-		/* The TI or RI interrupt bits may still be set even if using
-		 * per channel DMA interrupts. Check to be sure those are not
-		 * enabled before using the private data napi structure.
+		per_ch_irq = pdata->per_channel_irq;
+
+		/*
+		 * Decide which NAPI to use and whether to schedule:
+		 * - When not using per-channel IRQs: schedule on global NAPI
+		 *   if TI or RI are set.
 		 */
-		if (!pdata->per_channel_irq &&
-		    (XGMAC_GET_BITS(dma_ch_isr, DMA_CH_SR, TI) ||
-		     XGMAC_GET_BITS(dma_ch_isr, DMA_CH_SR, RI))) {
-			if (napi_schedule_prep(&pdata->napi)) {
-				/* Disable Tx and Rx interrupts */
-				xgbe_disable_rx_tx_ints(pdata);
-
-				/* Turn on polling */
-				__napi_schedule(&pdata->napi);
-			}
+		if (!per_ch_irq && (ti || ri))
+			schedule_napi = true;
+
+		napi = per_ch_irq ? &channel->napi : &pdata->napi;
+
+		if (schedule_napi && napi_schedule_prep(napi)) {
+			/* Disable interrupts appropriately before polling */
+			xgbe_disable_rx_tx_ints(pdata);
+
+			/* Turn on polling */
+			__napi_schedule(napi);
 		} else {
-			/* Don't clear Rx/Tx status if doing per channel DMA
-			 * interrupts, these will be cleared by the ISR for
-			 * per channel DMA interrupts.
+			/*
+			 * Don't clear Rx/Tx status if doing per-channel DMA
+			 * interrupts; those bits will be serviced/cleared by
+			 * the per-channel ISR/NAPI. In non-per-channel mode
+			 * when we're not scheduling NAPI here, ensure we don't
+			 * accidentally clear TI/RI in HW: zero them in the
+			 * local copy so that the eventual write-back does not
+			 * clear TI/RI.
 			 */
 			XGMAC_SET_BITS(dma_ch_isr, DMA_CH_SR, TI, 0);
 			XGMAC_SET_BITS(dma_ch_isr, DMA_CH_SR, RI, 0);
 		}
 
-		if (XGMAC_GET_BITS(dma_ch_isr, DMA_CH_SR, RBU))
+		if (rbu)
 			pdata->ext_stats.rx_buffer_unavailable++;
 
 		/* Restart the device on a Fatal Bus Error */
-		if (XGMAC_GET_BITS(dma_ch_isr, DMA_CH_SR, FBE))
+		if (fbe)
 			schedule_work(&pdata->restart_work);
 
 		/* Clear interrupt signals */
-- 
2.34.1


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

* [PATCH net-next v2 2/2] amd-xgbe: schedule NAPI on Rx Buffer Unavailable (RBU)
  2025-11-29 17:50 [PATCH net-next v2 0/2] amd-xgbe: schedule NAPI on RBU event Raju Rangoju
  2025-11-29 17:50 ` [PATCH net-next v2 1/2] amd-xgbe: refactor the dma IRQ handling code path Raju Rangoju
@ 2025-11-29 17:50 ` Raju Rangoju
  2025-12-01 22:50 ` [PATCH net-next v2 0/2] amd-xgbe: schedule NAPI on RBU event patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Raju Rangoju @ 2025-11-29 17:50 UTC (permalink / raw)
  To: netdev
  Cc: pabeni, kuba, edumazet, davem, andrew+netdev, Shyam-sundar.S-k,
	Raju Rangoju

Under heavy load, Rx Buffer Unavailable (RBU) can occur if Rx processing
is slower than network. When an RBU is signaled, try to schedule NAPI to
help recover from such situation (including cases where an IRQ may be
missed or such)

Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com>
---
 drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index aca1c57554d7..3ddd896d6987 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -410,15 +410,29 @@ static void xgbe_isr_bh_work(struct work_struct *work)
 		 * Decide which NAPI to use and whether to schedule:
 		 * - When not using per-channel IRQs: schedule on global NAPI
 		 *   if TI or RI are set.
+		 * - RBU should also trigger NAPI (either per-channel or global)
+		 *   to allow refill.
 		 */
 		if (!per_ch_irq && (ti || ri))
 			schedule_napi = true;
 
+		if (rbu) {
+			schedule_napi = true;
+			pdata->ext_stats.rx_buffer_unavailable++;
+		}
+
 		napi = per_ch_irq ? &channel->napi : &pdata->napi;
 
 		if (schedule_napi && napi_schedule_prep(napi)) {
 			/* Disable interrupts appropriately before polling */
-			xgbe_disable_rx_tx_ints(pdata);
+			if (per_ch_irq) {
+				if (pdata->channel_irq_mode)
+					xgbe_disable_rx_tx_int(pdata, channel);
+				else
+					disable_irq_nosync(channel->dma_irq);
+			} else {
+				xgbe_disable_rx_tx_ints(pdata);
+			}
 
 			/* Turn on polling */
 			__napi_schedule(napi);
@@ -436,9 +450,6 @@ static void xgbe_isr_bh_work(struct work_struct *work)
 			XGMAC_SET_BITS(dma_ch_isr, DMA_CH_SR, RI, 0);
 		}
 
-		if (rbu)
-			pdata->ext_stats.rx_buffer_unavailable++;
-
 		/* Restart the device on a Fatal Bus Error */
 		if (fbe)
 			schedule_work(&pdata->restart_work);
-- 
2.34.1


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

* Re: [PATCH net-next v2 0/2] amd-xgbe: schedule NAPI on RBU event
  2025-11-29 17:50 [PATCH net-next v2 0/2] amd-xgbe: schedule NAPI on RBU event Raju Rangoju
  2025-11-29 17:50 ` [PATCH net-next v2 1/2] amd-xgbe: refactor the dma IRQ handling code path Raju Rangoju
  2025-11-29 17:50 ` [PATCH net-next v2 2/2] amd-xgbe: schedule NAPI on Rx Buffer Unavailable (RBU) Raju Rangoju
@ 2025-12-01 22:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-12-01 22:50 UTC (permalink / raw)
  To: Raju Rangoju
  Cc: netdev, pabeni, kuba, edumazet, davem, andrew+netdev,
	Shyam-sundar.S-k

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Sat, 29 Nov 2025 23:20:14 +0530 you wrote:
> During the RX overload the Rx buffers may not be refilled, trying to
> schedule the NAPI when an Rx Buffer Unavailable is signaled may help in
> improving the such situation, in case we missed an IRQ.
> 
> Raju Rangoju (2):
>   amd-xgbe: refactor the dma IRQ handling code path
>   amd-xgbe: schedule NAPI on Rx Buffer Unavailable (RBU)
> 
> [...]

Here is the summary with links:
  - [net-next,v2,1/2] amd-xgbe: refactor the dma IRQ handling code path
    https://git.kernel.org/netdev/net-next/c/c3b744fd2019
  - [net-next,v2,2/2] amd-xgbe: schedule NAPI on Rx Buffer Unavailable (RBU)
    https://git.kernel.org/netdev/net-next/c/ab96af7004c7

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2025-12-01 22:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-29 17:50 [PATCH net-next v2 0/2] amd-xgbe: schedule NAPI on RBU event Raju Rangoju
2025-11-29 17:50 ` [PATCH net-next v2 1/2] amd-xgbe: refactor the dma IRQ handling code path Raju Rangoju
2025-11-29 17:50 ` [PATCH net-next v2 2/2] amd-xgbe: schedule NAPI on Rx Buffer Unavailable (RBU) Raju Rangoju
2025-12-01 22:50 ` [PATCH net-next v2 0/2] amd-xgbe: schedule NAPI on RBU event patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).