Browse Source

sfc: force removal of VF and vport on driver removal

When the driver unloads, force the unbind and removal of any
VFs in the host with the PF.  The PF cannot remove vports and
vswitches if they are still being used by a VF driver, and when
unloading the sfc driver the removal order is not guaranteed,
so the instruction from the PF to the VF to unbind enforces a
suitable ordering so that vswitches and vports can be removed.

As a result of this, manually unbinding the driver from a single
PF will result in all of its VFs in the host also being removed.

Signed-off-by: Shradha Shah <sshah@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Daniel Pieczko 10 years ago
parent
commit
2a3fc31122
2 changed files with 11 additions and 1 deletions
  1. 9 0
      drivers/net/ethernet/sfc/ef10_sriov.c
  2. 2 1
      drivers/net/ethernet/sfc/efx.c

+ 9 - 0
drivers/net/ethernet/sfc/ef10_sriov.c

@@ -448,11 +448,20 @@ int efx_ef10_sriov_init(struct efx_nic *efx)
 void efx_ef10_sriov_fini(struct efx_nic *efx)
 void efx_ef10_sriov_fini(struct efx_nic *efx)
 {
 {
 	struct efx_ef10_nic_data *nic_data = efx->nic_data;
 	struct efx_ef10_nic_data *nic_data = efx->nic_data;
+	unsigned int i;
 	int rc;
 	int rc;
 
 
 	if (!nic_data->vf)
 	if (!nic_data->vf)
 		return;
 		return;
 
 
+	/* Remove any VFs in the host */
+	for (i = 0; i < efx->vf_count; ++i) {
+		struct efx_nic *vf_efx = nic_data->vf[i].efx;
+
+		if (vf_efx)
+			vf_efx->pci_dev->driver->remove(vf_efx->pci_dev);
+	}
+
 	rc = efx_ef10_pci_sriov_disable(efx);
 	rc = efx_ef10_pci_sriov_disable(efx);
 	if (rc)
 	if (rc)
 		netif_dbg(efx, drv, efx->net_dev,
 		netif_dbg(efx, drv, efx->net_dev,

+ 2 - 1
drivers/net/ethernet/sfc/efx.c

@@ -2902,7 +2902,8 @@ static void efx_pci_remove_main(struct efx_nic *efx)
 }
 }
 
 
 /* Final NIC shutdown
 /* Final NIC shutdown
- * This is called only at module unload (or hotplug removal).
+ * This is called only at module unload (or hotplug removal).  A PF can call
+ * this on its VFs to ensure they are unbound first.
  */
  */
 static void efx_pci_remove(struct pci_dev *pci_dev)
 static void efx_pci_remove(struct pci_dev *pci_dev)
 {
 {