Commit 72f9c203 authored by Brett Creeley's avatar Brett Creeley Committed by Jeff Kirsher

ice: Gracefully handle reset failure in ice_alloc_vfs()

Currently if ice_reset_all_vfs() fails in ice_alloc_vfs() we fail to
free some resources, reset variables, and return an error value.
Fix this by adding another unroll case to free the pf->vf array, set
the pf->num_alloc_vfs to 0, and return an error code.

Without this, if ice_reset_all_vfs() fails in ice_alloc_vfs() we will
not be able to do SRIOV without hard rebooting the system because
rmmod'ing the driver does not work.
Signed-off-by: default avatarBrett Creeley <brett.creeley@intel.com>
Signed-off-by: default avatarAnirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent a17a5ff6
...@@ -1134,7 +1134,7 @@ static int ice_alloc_vfs(struct ice_pf *pf, u16 num_alloc_vfs) ...@@ -1134,7 +1134,7 @@ static int ice_alloc_vfs(struct ice_pf *pf, u16 num_alloc_vfs)
GFP_KERNEL); GFP_KERNEL);
if (!vfs) { if (!vfs) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_unroll_sriov; goto err_pci_disable_sriov;
} }
pf->vf = vfs; pf->vf = vfs;
...@@ -1154,12 +1154,19 @@ static int ice_alloc_vfs(struct ice_pf *pf, u16 num_alloc_vfs) ...@@ -1154,12 +1154,19 @@ static int ice_alloc_vfs(struct ice_pf *pf, u16 num_alloc_vfs)
pf->num_alloc_vfs = num_alloc_vfs; pf->num_alloc_vfs = num_alloc_vfs;
/* VF resources get allocated during reset */ /* VF resources get allocated during reset */
if (!ice_reset_all_vfs(pf, true)) if (!ice_reset_all_vfs(pf, true)) {
ret = -EIO;
goto err_unroll_sriov; goto err_unroll_sriov;
}
goto err_unroll_intr; goto err_unroll_intr;
err_unroll_sriov: err_unroll_sriov:
pf->vf = NULL;
devm_kfree(&pf->pdev->dev, vfs);
vfs = NULL;
pf->num_alloc_vfs = 0;
err_pci_disable_sriov:
pci_disable_sriov(pf->pdev); pci_disable_sriov(pf->pdev);
err_unroll_intr: err_unroll_intr:
/* rearm interrupts here */ /* rearm interrupts here */
......
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