net/mlx5: Read num_vfs before disabling SR-IOV
authorParav Pandit <parav@mellanox.com>
Mon, 28 Oct 2019 18:29:17 +0000 (13:29 -0500)
committerSaeed Mahameed <saeedm@mellanox.com>
Wed, 13 Nov 2019 22:25:03 +0000 (14:25 -0800)
commita7cba0a4d508d2d78f2932ee944feadd38c97c2c
tree041a2021d6db577aed7ad60958e6efd4b1f29e4d
parent86bb811b08086f98744ecc600907673af7f2aec5
net/mlx5: Read num_vfs before disabling SR-IOV

mlx5_device_disable_sriov() currently reads num_vfs from the PCI core.
However when mlx5_device_disable_sriov() is executed, SR-IOV is
already disabled at the PCI level.
Due to this disable_hca() cleanup is not done during SR-IOV disable
flow.

mlx5_sriov_disable()
  pci_enable_sriov()
  mlx5_device_disable_sriov() <- num_vfs is zero here.

When SR-IOV enablement fails during mlx5_sriov_enable(), HCA's are left
in enabled stage because mlx5_device_disable_sriov() relies on num_vfs
from PCI core.

mlx5_sriov_enable()
  mlx5_device_enable_sriov()
  pci_enable_sriov() <- Fails

Hence, to overcome above issues,
(a) Read num_vfs before disabling SR-IOV and use it.
(b) Use num_vfs given when enabling sriov in error unwinding path.

Fixes: d886aba677a0 ("net/mlx5: Reduce dependency on enabled_vfs counter and num_vfs")
Signed-off-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Daniel Jurgens <danielj@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/sriov.c