Skip to contentSkip to conversation

ixgbe, xsk: clean up the resources in ixgbe_xsk_pool_enable error path

PATCH In review Wang Hai 3 participants 3 messages Jun 7, 2021 – Aug 17, 2021

Subsystems (4)
lore
Share & tools
lore

Wang Hai

author
#0 lore raw

PATCH 1/1 ixgbe, xsk: clean up the resources in ixgbe_xsk_pool_enable error path

In ixgbe_xsk_pool_enable(), if ixgbe_xsk_wakeup() fails, We should restore the previous state and clean up the resources. Add the missing clear af_xdp_zc_qps and unmap dma to fix this bug.

Fixes d49e286d354e ("ixgbe: add tracking of AF_XDP zero-copy state for each queue pair")
Fixes 4a9b32f30f80 ("ixgbe: fix potential RX buffer starvation for AF_XDP")
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +4 -1
index 91ad5b902673..d912f14d2ba4 100644
@@ -52,8 +52,11 @@ static int ixgbe_xsk_pool_enable(struct ixgbe_adapter *adapter,
 
 		/* Kick start the NAPI context so that receiving will start */
 		err = ixgbe_xsk_wakeup(adapter->netdev, qid, XDP_WAKEUP_RX);
-		if (err)
+		if (err) {
+			clear_bit(qid, adapter->af_xdp_zc_qps);
+			xsk_pool_dma_unmap(pool, IXGBE_RX_DMA_ATTR);
 			return err;
+		}
 	}
 
 	return 0;
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Wang Hai

In ixgbe_xsk_pool_enable(), if ixgbe_xsk_wakeup() fails, We should restore the previous state and clean up the resources. Add the missing clear af_xdp_zc_qps and unmap dma to fix this bug.

Quoted 6 lines
Fixes d49e286d354e ("ixgbe: add tracking of AF_XDP zero-copy state for each queue pair")
Fixes 4a9b32f30f80 ("ixgbe: fix potential RX buffer starvation for AF_XDP")
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Thanks Wang.

Quoted 24 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +4 -2
index 91ad5b902673..d912f14d2ba4 100644
@@ -52,8 +52,11 @@ static int ixgbe_xsk_pool_enable(struct ixgbe_adapter *adapter,
 
                /* Kick start the NAPI context so that receiving will start */
                err = ixgbe_xsk_wakeup(adapter->netdev, qid, XDP_WAKEUP_RX);
-               if (err)
+               if (err) {
+                       clear_bit(qid, adapter->af_xdp_zc_qps);
+                       xsk_pool_dma_unmap(pool, IXGBE_RX_DMA_ATTR);
                        return err;
+               }
        }
 
        return 0;
--

2.17.1

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan at osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

Tested-by on v1 1/1
#2 lore raw
In reply to Wang Hai
Quoted 19 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Wang Hai
Sent: Monday, June 7, 2021 5:57 PM
To: Brandeburg, Jesse <[email protected]>; Nguyen, Anthony L <[email protected]>; davem at davemloft.net; ast at kernel.org; kuba at kernel.org; daniel at iogearbox.net; hawk at kernel.org; john.fastabend at gmail.com; jeffrey.t.kirsher at intel.com; Sokolowski, Jan <[email protected]>; Karlsson, Magnus <[email protected]>
Cc: netdev at vger.kernel.org; bpf at vger.kernel.org; intel-wired- lan at lists.osuosl.org; linux-kernel at vger.kernel.org
Subject: [Intel-wired-lan] [PATCH net] ixgbe, xsk: clean up the resources in ixgbe_xsk_pool_enable error path

In ixgbe_xsk_pool_enable(), if ixgbe_xsk_wakeup() fails, We should restore the previous state and clean up the resources. Add the missing clear af_xdp_zc_qps and unmap dma to fix this bug.

Quoted 8 lines
Fixes d49e286d354e ("ixgbe: add tracking of AF_XDP zero-copy state for each

queue pair")

Fixes 4a9b32f30f80 ("ixgbe: fix potential RX buffer starvation for AF_XDP")

---
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 5 ++++-

1 file changed, 4 insertions(+), 1 deletion(-)