Intel Wired LAN Driver Updates 2022-09-02 (ice)
Subsystems (4)
Tony Nguyen
maintainerThis series contains updates to ice driver only.
Przemyslaw fixes memory leak of DMA memory due to incorrect freeing of rx_buf.
Michal S corrects incorrect call to free memory.
---
v2: Removed patch 3
The following are changes since commit e7506d344bf180096a86ec393515861fb5245915:
Merge tag 'rxrpc-fixes-20220901' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue 100GbE
Michal Swiatkowski (1):
ice: use bitmap_free instead of devm_kfree
Przemyslaw Patynowski (1):
ice: Fix DMA mappings leak
drivers/net/ethernet/intel/ice/ice_base.c | 17 ------ drivers/net/ethernet/intel/ice/ice_main.c | 10 +++- drivers/net/ethernet/intel/ice/ice_xsk.c | 63 +++++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_xsk.h | 8 +++ 4 files changed, 80 insertions(+), 18 deletions(-)
Signature · 1 line
2.35.1
Tony Nguyen
maintainerPATCH v2 1/2 ice: Fix DMA mappings leak
From: Przemyslaw Patynowski <[email protected]>
Fix leak, when user changes ring parameters.
During reallocation of RX buffers, new DMA mappings are created for those buffers. New buffers with different RX ring count should substitute older ones, but those buffers were freed in ice_vsi_cfg_rxq and reallocated again with ice_alloc_rx_buf. kfree on rx_buf caused leak of already mapped DMA.
Reallocate ZC with xdp_buf struct, when BPF program loads. Reallocate back to rx_buf, when BPF program unloads.
If BPF program is loaded/unloaded and XSK pools are created, reallocate RX queues accordingly in XDP_SETUP_XSK_POOL handler.
Steps for reproduction:
while :
do
for ((i=0; i<=8160; i=i+32)) do ethtool -G enp130s0f0 rx $i tx $i sleep 0.5 ethtool -g enp130s0f0 done
done
--- drivers/net/ethernet/intel/ice/ice_base.c | 17 ------ drivers/net/ethernet/intel/ice/ice_main.c | 8 +++ drivers/net/ethernet/intel/ice/ice_xsk.c | 63 +++++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_xsk.h | 8 +++ 4 files changed, 79 insertions(+), 17 deletions(-)
drivers/net/ethernet/intel/ice/ice_base.c +0 -17
@@ -7,18 +7,6 @@#include "ice_dcb_lib.h" #include "ice_sriov.h" -static bool ice_alloc_rx_buf_zc (struct ice_rx_ring *rx_ring) -{ - rx_ring->xdp_buf =kcalloc (rx_ring->count,sizeof (*rx_ring->xdp_buf),GFP_KERNEL ); -return !!rx_ring->xdp_buf; -} - -static bool ice_alloc_rx_buf (struct ice_rx_ring *rx_ring) -{ - rx_ring->rx_buf =kcalloc (rx_ring->count,sizeof (*rx_ring->rx_buf),GFP_KERNEL ); -return !!rx_ring->rx_buf; -} -/** * __ice_vsi_get_qs_contig - Assign a contiguous chunk of queues to VSI * @qs_cfg: gathered variables needed for PF->VSI queues assignment
@@ -519,11 +507,8 @@ int ice_vsi_cfg_rxq(struct ice_rx_ring *ring)xdp_rxq_info_reg (&ring->xdp_rxq, ring->netdev, ring->q_index, ring->q_vector->napi.napi_id); -kfree (ring->rx_buf); ring->xsk_pool =ice_xsk_pool (ring);if (ring->xsk_pool) { -if (!ice_alloc_rx_buf_zc (ring)) -return -ENOMEM ;xdp_rxq_info_unreg_mem_model (&ring->xdp_rxq); ring->rx_buf_len =
@@ -538,8 +523,6 @@ int ice_vsi_cfg_rxq(struct ice_rx_ring *ring)dev_info (dev,"Registered XDP mem model MEM_TYPE_XSK_BUFF_POOL on Rx ring %d\n" , ring->q_index); }else { -if (!ice_alloc_rx_buf (ring)) -return -ENOMEM ;if (!xdp_rxq_info_is_reg (&ring->xdp_rxq))/* coverity[check_return] */ xdp_rxq_info_reg(&ring->xdp_rxq,
drivers/net/ethernet/intel/ice/ice_main.c +8 -0
@@ -2898,10 +2898,18 @@ ice_xdp_setup_prog(struct ice_vsi *vsi, struct bpf_prog *prog,if (xdp_ring_err)NL_SET_ERR_MSG_MOD (extack,"Setting up XDP Tx resources failed" ); } +/* reallocate Rx queues that are used for zero-copy */ + xdp_ring_err =ice_realloc_zc_buf (vsi, true); +if (xdp_ring_err) +NL_SET_ERR_MSG_MOD (extack,"Setting up XDP Rx resources failed" ); }else if (ice_is_xdp_ena_vsi (vsi) && !prog) { xdp_ring_err =ice_destroy_xdp_rings (vsi);if (xdp_ring_err)NL_SET_ERR_MSG_MOD (extack,"Freeing XDP Tx resources failed" ); +/* reallocate Rx queues that were used for zero-copy */ + xdp_ring_err =ice_realloc_zc_buf (vsi, false); +if (xdp_ring_err) +NL_SET_ERR_MSG_MOD (extack,"Freeing XDP Rx resources failed" ); }else {/* safe to call even when prog == vsi->xdp_prog as * dev_xdp_install in net/core/dev.c incremented prog's
drivers/net/ethernet/intel/ice/ice_xsk.c +63 -0
86 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_xsk.h +8 -0
@@ -27,6 +27,7 @@ bool ice_xsk_any_rx_ring_ena(struct ice_vsi *vsi);void ice_xsk_clean_rx_ring (struct ice_rx_ring *rx_ring);void ice_xsk_clean_xdp_ring (struct ice_tx_ring *xdp_ring);bool ice_xmit_zc (struct ice_tx_ring *xdp_ring,u32 budget,int napi_budget); +int ice_realloc_zc_buf (struct ice_vsi *vsi,bool zc);#else static inline bool ice_xmit_zc(struct ice_tx_ring __always_unused *xdp_ring,
@@ -72,5 +73,12 @@ ice_xsk_wakeup(struct net_device __always_unused *netdev,static inline void ice_xsk_clean_rx_ring (struct ice_rx_ring *rx_ring) { }static inline void ice_xsk_clean_xdp_ring (struct ice_tx_ring *xdp_ring) { } + +static inline int +ice_realloc_zc_buf (struct ice_vsi __always_unused *vsi, +bool __always_unused zc) +{ +return 0 ; +}#endif /* CONFIG_XDP_SOCKETS */ #endif /* !_ICE_XSK_H_ */
Signature · 1 line
2.35.1
Tony Nguyen
maintainerPATCH v2 2/2 ice: use bitmap_free instead of devm_kfree
In reply to Tony NguyenFrom: Michal Swiatkowski <[email protected]>
pf->avail_txqs was allocated using bitmap_zalloc, bitmap_free should be used to free this memory.
--- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_main.c +1 -1
@@ -3913,7 +3913,7 @@ static int ice_init_pf(struct ice_pf *pf) pf->avail_rxqs =bitmap_zalloc (pf->max_pf_rxqs,GFP_KERNEL );if (!pf->avail_rxqs) { -devm_kfree (ice_pf_to_dev (pf), pf->avail_txqs); +bitmap_free (pf->avail_txqs); pf->avail_txqs =NULL ;return -ENOMEM ; }
Signature · 1 line
2.35.1
This series was applied to netdev/net.git (master) by Tony Nguyen <[email protected]>:
Hello:
This series was applied to netdev/net.git (master) by Tony Nguyen <[email protected]>:
Quoted 8 lines · On Fri, 2 Sep 2022 10:57:01 -0700 you wrote:
This series contains updates to ice driver only.
Przemyslaw fixes memory leak of DMA memory due to incorrect freeing of
rx_buf.Michal S corrects incorrect call to free memory.
[...]
Here is the summary with links:
- [net,v2,1/2] ice: Fix DMA mappings leak
https://git.kernel.org/netdev/net/c/7e753eb675f0 - [net,v2,2/2] ice: use bitmap_free instead of devm_kfree https://git.kernel.org/netdev/net/c/59ac325557b6
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html