From: Daniel Pieczko Date: Tue, 2 Jun 2015 10:40:31 +0000 (+0100) Subject: sfc: do not allow VFs to be destroyed if assigned to guests X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=71158bf2e748e2710616f59a823619af3c5505a7;p=linux-beck.git sfc: do not allow VFs to be destroyed if assigned to guests Signed-off-by: Shradha Shah Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/sfc/ef10_sriov.c b/drivers/net/ethernet/sfc/ef10_sriov.c index cd524543c363..083c534bc4ec 100644 --- a/drivers/net/ethernet/sfc/ef10_sriov.c +++ b/drivers/net/ethernet/sfc/ef10_sriov.c @@ -417,6 +417,15 @@ static int efx_ef10_pci_sriov_disable(struct efx_nic *efx) { struct pci_dev *dev = efx->pci_dev; + if (!efx->vf_count) + return 0; + + if (pci_vfs_assigned(dev)) { + netif_err(efx, drv, efx->net_dev, "VFs are assigned to guests; " + "please detach them before disabling SR-IOV\n"); + return -EBUSY; + } + pci_disable_sriov(dev); efx_ef10_sriov_free_vf_vswitching(efx); efx->vf_count = 0;