Skip to content

Commit f9124c6

Browse files
mfijalkoanguy11
authored andcommitted
ice: synchronize_rcu() when terminating rings
Unfortunately, the ice driver doesn't respect the RCU critical section that XSK wakeup is surrounded with. To fix this, add synchronize_rcu() calls to paths that destroy resources that might be in use. This was addressed in other AF_XDP ZC enabled drivers, for reference see for example commit b3873a5 ("net/i40e: Fix concurrency issues between config flow and XSK") Fixes: efc2214 ("ice: Add support for XDP") Fixes: 2d4238f ("ice: Add support for AF_XDP") Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Tested-by: Shwetha Nagaraju <shwetha.nagaraju@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 1158f79 commit f9124c6

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ static inline struct ice_pf *ice_netdev_to_pf(struct net_device *netdev)
671671

672672
static inline bool ice_is_xdp_ena_vsi(struct ice_vsi *vsi)
673673
{
674-
return !!vsi->xdp_prog;
674+
return !!READ_ONCE(vsi->xdp_prog);
675675
}
676676

677677
static inline void ice_set_ring_xdp(struct ice_tx_ring *ring)

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2758,8 +2758,10 @@ int ice_destroy_xdp_rings(struct ice_vsi *vsi)
27582758

27592759
ice_for_each_xdp_txq(vsi, i)
27602760
if (vsi->xdp_rings[i]) {
2761-
if (vsi->xdp_rings[i]->desc)
2761+
if (vsi->xdp_rings[i]->desc) {
2762+
synchronize_rcu();
27622763
ice_free_tx_ring(vsi->xdp_rings[i]);
2764+
}
27632765
kfree_rcu(vsi->xdp_rings[i], rcu);
27642766
vsi->xdp_rings[i] = NULL;
27652767
}

drivers/net/ethernet/intel/ice/ice_xsk.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ static void ice_qp_reset_stats(struct ice_vsi *vsi, u16 q_idx)
4141
static void ice_qp_clean_rings(struct ice_vsi *vsi, u16 q_idx)
4242
{
4343
ice_clean_tx_ring(vsi->tx_rings[q_idx]);
44-
if (ice_is_xdp_ena_vsi(vsi))
44+
if (ice_is_xdp_ena_vsi(vsi)) {
45+
synchronize_rcu();
4546
ice_clean_tx_ring(vsi->xdp_rings[q_idx]);
47+
}
4648
ice_clean_rx_ring(vsi->rx_rings[q_idx]);
4749
}
4850

0 commit comments

Comments
 (0)