]> git.baikalelectronics.ru Git - kernel.git/commit
ice: use ice_for_each_vf for iteration during removal
authorJacob Keller <jacob.e.keller@intel.com>
Wed, 16 Feb 2022 21:37:34 +0000 (13:37 -0800)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Thu, 3 Mar 2022 16:46:48 +0000 (08:46 -0800)
commit83643cc4a528068793e71addbf74453eb5761dca
tree38304523fd093baa4e7f63afde3f840ed0d4c273
parent8e6c5ff62a158c1cb4f1a25b5f119f5bc6b0a1e8
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>
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c