Skip to content

Commit 19281e8

Browse files
jacob-kelleranguy11
authored andcommitted
ice: use ice_for_each_vf for iteration during removal
When removing VFs, the driver takes a weird approach of assigning pf->num_alloc_vfs to 0 before iterating over the VFs using a temporary variable. This logic has been in the driver for a long time, and seems to have been carried forward from i40e. We want to refactor the way VFs are stored, and iterating over the data structure without the ice_for_each_vf interface impedes this work. The logic relies on implicitly using the num_alloc_vfs as a sort of "safe guard" for accessing VF data. While this sort of guard makes sense for Single Root IOV where all VFs are added at once, the data structures don't work for VFs which can be added and removed dynamically. We also have a separate state flag, ICE_VF_DEINIT_IN_PROGRESS which is a stronger protection against concurrent removal and access. Avoid the custom tmp iteration and replace it with the standard ice_for_each_vf iterator. Delay the assignment of num_alloc_vfs until after this loop finishes. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 59e1f85 commit 19281e8

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ void ice_free_vfs(struct ice_pf *pf)
500500
{
501501
struct device *dev = ice_pf_to_dev(pf);
502502
struct ice_hw *hw = &pf->hw;
503-
unsigned int tmp, i;
503+
unsigned int i;
504504

505505
if (!pf->vf)
506506
return;
@@ -519,10 +519,7 @@ void ice_free_vfs(struct ice_pf *pf)
519519
else
520520
dev_warn(dev, "VFs are assigned - not disabling SR-IOV\n");
521521

522-
tmp = pf->num_alloc_vfs;
523-
pf->num_qps_per_vf = 0;
524-
pf->num_alloc_vfs = 0;
525-
for (i = 0; i < tmp; i++) {
522+
ice_for_each_vf(pf, i) {
526523
struct ice_vf *vf = &pf->vf[i];
527524

528525
mutex_lock(&vf->cfg_lock);
@@ -558,6 +555,8 @@ void ice_free_vfs(struct ice_pf *pf)
558555
if (ice_sriov_free_msix_res(pf))
559556
dev_err(dev, "Failed to free MSIX resources used by SR-IOV\n");
560557

558+
pf->num_qps_per_vf = 0;
559+
pf->num_alloc_vfs = 0;
561560
devm_kfree(dev, pf->vf);
562561
pf->vf = NULL;
563562

0 commit comments

Comments
 (0)