Commit f9124c68 authored by Maciej Fijalkowski's avatar Maciej Fijalkowski Committed by Tony Nguyen

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 b3873a5b ("net/i40e: Fix concurrency issues
between config flow and XSK")

Fixes: efc2214b ("ice: Add support for XDP")
Fixes: 2d4238f5 ("ice: Add support for AF_XDP")
Signed-off-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
Tested-by: default avatarShwetha Nagaraju <shwetha.nagaraju@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 1158f79f
...@@ -671,7 +671,7 @@ static inline struct ice_pf *ice_netdev_to_pf(struct net_device *netdev) ...@@ -671,7 +671,7 @@ static inline struct ice_pf *ice_netdev_to_pf(struct net_device *netdev)
static inline bool ice_is_xdp_ena_vsi(struct ice_vsi *vsi) static inline bool ice_is_xdp_ena_vsi(struct ice_vsi *vsi)
{ {
return !!vsi->xdp_prog; return !!READ_ONCE(vsi->xdp_prog);
} }
static inline void ice_set_ring_xdp(struct ice_tx_ring *ring) static inline void ice_set_ring_xdp(struct ice_tx_ring *ring)
......
...@@ -2758,8 +2758,10 @@ int ice_destroy_xdp_rings(struct ice_vsi *vsi) ...@@ -2758,8 +2758,10 @@ int ice_destroy_xdp_rings(struct ice_vsi *vsi)
ice_for_each_xdp_txq(vsi, i) ice_for_each_xdp_txq(vsi, i)
if (vsi->xdp_rings[i]) { if (vsi->xdp_rings[i]) {
if (vsi->xdp_rings[i]->desc) if (vsi->xdp_rings[i]->desc) {
synchronize_rcu();
ice_free_tx_ring(vsi->xdp_rings[i]); ice_free_tx_ring(vsi->xdp_rings[i]);
}
kfree_rcu(vsi->xdp_rings[i], rcu); kfree_rcu(vsi->xdp_rings[i], rcu);
vsi->xdp_rings[i] = NULL; vsi->xdp_rings[i] = NULL;
} }
......
...@@ -41,8 +41,10 @@ static void ice_qp_reset_stats(struct ice_vsi *vsi, u16 q_idx) ...@@ -41,8 +41,10 @@ static void ice_qp_reset_stats(struct ice_vsi *vsi, u16 q_idx)
static void ice_qp_clean_rings(struct ice_vsi *vsi, u16 q_idx) static void ice_qp_clean_rings(struct ice_vsi *vsi, u16 q_idx)
{ {
ice_clean_tx_ring(vsi->tx_rings[q_idx]); ice_clean_tx_ring(vsi->tx_rings[q_idx]);
if (ice_is_xdp_ena_vsi(vsi)) if (ice_is_xdp_ena_vsi(vsi)) {
synchronize_rcu();
ice_clean_tx_ring(vsi->xdp_rings[q_idx]); ice_clean_tx_ring(vsi->xdp_rings[q_idx]);
}
ice_clean_rx_ring(vsi->rx_rings[q_idx]); ice_clean_rx_ring(vsi->rx_rings[q_idx]);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment