Commit 1ebe4feb authored by Íñigo Huguet's avatar Íñigo Huguet Committed by David S. Miller

sfc: error code if SRIOV cannot be disabled

If SRIOV cannot be disabled during device removal or module unloading,
return error code so it can be logged properly in the calling function.

Note that this can only happen if any VF is currently attached to a
guest using Xen, but not with vfio/KVM. Despite that in that case the
VFs won't work properly with PF removed and/or the module unloaded, I
have let it as is because I don't know what side effects may have
changing it, and also it seems to be the same that other drivers are
doing in this situation.

In the case of being called during SRIOV reconfiguration, the behavior
hasn't changed because the function is called with force=false.
Signed-off-by: default avatarÍñigo Huguet <ihuguet@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 45423cff
...@@ -402,12 +402,17 @@ static int efx_ef10_pci_sriov_enable(struct efx_nic *efx, int num_vfs) ...@@ -402,12 +402,17 @@ static int efx_ef10_pci_sriov_enable(struct efx_nic *efx, int num_vfs)
return rc; return rc;
} }
/* Disable SRIOV and remove VFs
* If some VFs are attached to a guest (using Xen, only) nothing is
* done if force=false, and vports are freed if force=true (for the non
* attachedc ones, only) but SRIOV is not disabled and VFs are not
* removed in either case.
*/
static int efx_ef10_pci_sriov_disable(struct efx_nic *efx, bool force) static int efx_ef10_pci_sriov_disable(struct efx_nic *efx, bool force)
{ {
struct pci_dev *dev = efx->pci_dev; struct pci_dev *dev = efx->pci_dev;
unsigned int vfs_assigned = 0; unsigned int vfs_assigned = pci_vfs_assigned(dev);
int rc = 0;
vfs_assigned = pci_vfs_assigned(dev);
if (vfs_assigned && !force) { if (vfs_assigned && !force) {
netif_info(efx, drv, efx->net_dev, "VFs are assigned to guests; " netif_info(efx, drv, efx->net_dev, "VFs are assigned to guests; "
...@@ -417,10 +422,12 @@ static int efx_ef10_pci_sriov_disable(struct efx_nic *efx, bool force) ...@@ -417,10 +422,12 @@ static int efx_ef10_pci_sriov_disable(struct efx_nic *efx, bool force)
if (!vfs_assigned) if (!vfs_assigned)
pci_disable_sriov(dev); pci_disable_sriov(dev);
else
rc = -EBUSY;
efx_ef10_sriov_free_vf_vswitching(efx); efx_ef10_sriov_free_vf_vswitching(efx);
efx->vf_count = 0; efx->vf_count = 0;
return 0; return rc;
} }
int efx_ef10_sriov_configure(struct efx_nic *efx, int num_vfs) int efx_ef10_sriov_configure(struct efx_nic *efx, int num_vfs)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment