Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[linux-block.git] / drivers / net / ethernet / intel / ice / ice_vf_lib.c
index b95931272b16ea342a1c567fdd9f260795535b0a..24e4f4d897b6667d717683f1e52aa0ab2db033b5 100644 (file)
@@ -185,25 +185,6 @@ int ice_check_vf_ready_for_cfg(struct ice_vf *vf)
        return 0;
 }
 
-/**
- * ice_check_vf_ready_for_reset - check if VF is ready to be reset
- * @vf: VF to check if it's ready to be reset
- *
- * The purpose of this function is to ensure that the VF is not in reset,
- * disabled, and is both initialized and active, thus enabling us to safely
- * initialize another reset.
- */
-int ice_check_vf_ready_for_reset(struct ice_vf *vf)
-{
-       int ret;
-
-       ret = ice_check_vf_ready_for_cfg(vf);
-       if (!ret && !test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states))
-               ret = -EAGAIN;
-
-       return ret;
-}
-
 /**
  * ice_trigger_vf_reset - Reset a VF on HW
  * @vf: pointer to the VF structure
@@ -862,11 +843,17 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags)
                return 0;
        }
 
+       if (flags & ICE_VF_RESET_LOCK)
+               mutex_lock(&vf->cfg_lock);
+       else
+               lockdep_assert_held(&vf->cfg_lock);
+
        if (ice_is_vf_disabled(vf)) {
                vsi = ice_get_vf_vsi(vf);
                if (!vsi) {
                        dev_dbg(dev, "VF is already removed\n");
-                       return -EINVAL;
+                       err = -EINVAL;
+                       goto out_unlock;
                }
                ice_vsi_stop_lan_tx_rings(vsi, ICE_NO_RESET, vf->vf_id);
 
@@ -875,14 +862,9 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags)
 
                dev_dbg(dev, "VF is already disabled, there is no need for resetting it, telling VM, all is fine %d\n",
                        vf->vf_id);
-               return 0;
+               goto out_unlock;
        }
 
-       if (flags & ICE_VF_RESET_LOCK)
-               mutex_lock(&vf->cfg_lock);
-       else
-               lockdep_assert_held(&vf->cfg_lock);
-
        /* Set VF disable bit state here, before triggering reset */
        set_bit(ICE_VF_STATE_DIS, vf->vf_states);
        ice_trigger_vf_reset(vf, flags & ICE_VF_RESET_VFLR, false);