Skip to content

Commit 6a9ddb3

Browse files
mawilli1Jeff Kirsher
authored andcommitted
i40e: disable IOV before freeing resources
If VF drivers are loaded in the host OS, the call to pci_disable_sriov() will cause these drivers' remove routines to be called. If the PF driver has already freed VF resources before this happens, then the VF remove routine can't properly communicate with the PF driver causing all sorts of mayhem and error messages and hurt feelings. To fix this, we move the call to pci_disable_sriov() up to the top of the function and let it complete before freeing any VF resources. Change-ID: I397c3997a00f6408e32b7735273911e499600236 Signed-off-by: Mitch Williams <[email protected]> Acked-by: Shannon Nelson <[email protected]> Tested-by: Jim Young <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 52e3ad9 commit 6a9ddb3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,10 +791,18 @@ void i40e_free_vfs(struct i40e_pf *pf)
791791
if (!pf->vf)
792792
return;
793793

794+
/* Disable IOV before freeing resources. This lets any VF drivers
795+
* running in the host get themselves cleaned up before we yank
796+
* the carpet out from underneath their feet.
797+
*/
798+
if (!pci_vfs_assigned(pf->pdev))
799+
pci_disable_sriov(pf->pdev);
800+
801+
msleep(20); /* let any messages in transit get finished up */
802+
794803
/* Disable interrupt 0 so we don't try to handle the VFLR. */
795804
i40e_irq_dynamic_disable_icr0(pf);
796805

797-
mdelay(10); /* let any messages in transit get finished up */
798806
/* free up vf resources */
799807
tmp = pf->num_alloc_vfs;
800808
pf->num_alloc_vfs = 0;
@@ -813,7 +821,6 @@ void i40e_free_vfs(struct i40e_pf *pf)
813821
* before this function ever gets called.
814822
*/
815823
if (!pci_vfs_assigned(pf->pdev)) {
816-
pci_disable_sriov(pf->pdev);
817824
/* Acknowledge VFLR for all VFS. Without this, VFs will fail to
818825
* work correctly when SR-IOV gets re-enabled.
819826
*/

0 commit comments

Comments
 (0)