Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@xxxxxxxxx> --- drivers/net/ethernet/intel/ice/ice_lib.c | 46 +++++++++++++----------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c index f559e60992fa..8ccdda69a1d4 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c @@ -2625,14 +2625,34 @@ void ice_vsi_free_rx_rings(struct ice_vsi *vsi) */ void ice_vsi_close(struct ice_vsi *vsi) { - if (!test_and_set_bit(ICE_VSI_DOWN, vsi->state)) - ice_down(vsi); + if (test_bit(ICE_VSI_DOWN, vsi->state)) + return; + + set_bit(ICE_VSI_DOWN, vsi->state); + ice_down(vsi); ice_vsi_free_irq(vsi); ice_vsi_free_tx_rings(vsi); ice_vsi_free_rx_rings(vsi); } +/** + * __ice_vsi_close - variant of shutting down a VSI that takes care of + * rtnl_lock + * @vsi: the VSI being shut down + * @take_lock: to lock or not to lock + */ +static void __ice_vsi_close(struct ice_vsi *vsi, bool take_lock) +{ + if (take_lock) + rtnl_lock(); + + ice_vsi_close(vsi); + + if (take_lock) + rtnl_unlock(); +} + /** * ice_ena_vsi - resume a VSI * @vsi: the VSI being resume @@ -2671,26 +2691,12 @@ int ice_ena_vsi(struct ice_vsi *vsi, bool locked) */ void ice_dis_vsi(struct ice_vsi *vsi, bool locked) { - if (test_bit(ICE_VSI_DOWN, vsi->state)) - return; - set_bit(ICE_VSI_NEEDS_RESTART, vsi->state); - if (vsi->type == ICE_VSI_PF && vsi->netdev) { - if (netif_running(vsi->netdev)) { - if (!locked) - rtnl_lock(); - - ice_vsi_close(vsi); - - if (!locked) - rtnl_unlock(); - } else { - ice_vsi_close(vsi); - } - } else if (vsi->type == ICE_VSI_CTRL) { - ice_vsi_close(vsi); - } + if (vsi->type == ICE_VSI_PF && vsi->netdev) + __ice_vsi_close(vsi, !locked && netif_running(vsi->netdev)); + else if (vsi->type == ICE_VSI_CTRL) + __ice_vsi_close(vsi, false); } /** -- 2.34.1 > > > > > > > if (!locked) > > > rtnl_unlock(); > > > - } else { > > > + } else if (!already_down) { > > > ice_vsi_close(vsi); > > > } > > > - } else if (vsi->type == ICE_VSI_CTRL) { > > > + } else if (vsi->type == ICE_VSI_CTRL && !already_down) { > > > ice_vsi_close(vsi); > > > } > > > } > > > -- > > > 2.43.0 > > >