nfp: reorder SR-IOV config and nfp_app SR-IOV callbacks
We previously assumed that app callback can be guaranteed to be executed before SR-IOV is actually enabled. Given that we can't guarantee that SR-IOV will be disabled during probe or that we will be able to disable it on remove, we should reorder the callbacks. We should also call the app's sriov_enable if SR-IOV was enabled during probe. Application FW must be able to disable VFs internally and not depend on them being removed at PCIe level. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Simon Horman <simon.horman@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
0dc7862191
commit
e3f28473b8
|
@ -107,17 +107,18 @@ static int nfp_pcie_sriov_enable(struct pci_dev *pdev, int num_vfs)
|
||||||
goto err_unlock;
|
goto err_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = nfp_app_sriov_enable(pf->app, num_vfs);
|
err = pci_enable_sriov(pdev, num_vfs);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_warn(&pdev->dev, "App specific PCI sriov configuration failed: %d\n",
|
dev_warn(&pdev->dev, "Failed to enable PCI SR-IOV: %d\n", err);
|
||||||
err);
|
|
||||||
goto err_unlock;
|
goto err_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = pci_enable_sriov(pdev, num_vfs);
|
err = nfp_app_sriov_enable(pf->app, num_vfs);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_warn(&pdev->dev, "Failed to enable PCI sriov: %d\n", err);
|
dev_warn(&pdev->dev,
|
||||||
goto err_app_sriov_disable;
|
"App specific PCI SR-IOV configuration failed: %d\n",
|
||||||
|
err);
|
||||||
|
goto err_sriov_disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pf->num_vfs = num_vfs;
|
pf->num_vfs = num_vfs;
|
||||||
|
@ -127,8 +128,8 @@ static int nfp_pcie_sriov_enable(struct pci_dev *pdev, int num_vfs)
|
||||||
mutex_unlock(&pf->lock);
|
mutex_unlock(&pf->lock);
|
||||||
return num_vfs;
|
return num_vfs;
|
||||||
|
|
||||||
err_app_sriov_disable:
|
err_sriov_disable:
|
||||||
nfp_app_sriov_disable(pf->app);
|
pci_disable_sriov(pdev);
|
||||||
err_unlock:
|
err_unlock:
|
||||||
mutex_unlock(&pf->lock);
|
mutex_unlock(&pf->lock);
|
||||||
return err;
|
return err;
|
||||||
|
@ -136,17 +137,20 @@ err_unlock:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __nfp_pcie_sriov_disable(struct pci_dev *pdev)
|
static int nfp_pcie_sriov_disable(struct pci_dev *pdev)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_PCI_IOV
|
#ifdef CONFIG_PCI_IOV
|
||||||
struct nfp_pf *pf = pci_get_drvdata(pdev);
|
struct nfp_pf *pf = pci_get_drvdata(pdev);
|
||||||
|
|
||||||
|
mutex_lock(&pf->lock);
|
||||||
|
|
||||||
/* If the VFs are assigned we cannot shut down SR-IOV without
|
/* If the VFs are assigned we cannot shut down SR-IOV without
|
||||||
* causing issues, so just leave the hardware available but
|
* causing issues, so just leave the hardware available but
|
||||||
* disabled
|
* disabled
|
||||||
*/
|
*/
|
||||||
if (pci_vfs_assigned(pdev)) {
|
if (pci_vfs_assigned(pdev)) {
|
||||||
dev_warn(&pdev->dev, "Disabling while VFs assigned - VFs will not be deallocated\n");
|
dev_warn(&pdev->dev, "Disabling while VFs assigned - VFs will not be deallocated\n");
|
||||||
|
mutex_unlock(&pf->lock);
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,22 +160,12 @@ static int __nfp_pcie_sriov_disable(struct pci_dev *pdev)
|
||||||
|
|
||||||
pci_disable_sriov(pdev);
|
pci_disable_sriov(pdev);
|
||||||
dev_dbg(&pdev->dev, "Removed VFs.\n");
|
dev_dbg(&pdev->dev, "Removed VFs.\n");
|
||||||
|
|
||||||
|
mutex_unlock(&pf->lock);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nfp_pcie_sriov_disable(struct pci_dev *pdev)
|
|
||||||
{
|
|
||||||
struct nfp_pf *pf = pci_get_drvdata(pdev);
|
|
||||||
int err;
|
|
||||||
|
|
||||||
mutex_lock(&pf->lock);
|
|
||||||
err = __nfp_pcie_sriov_disable(pdev);
|
|
||||||
mutex_unlock(&pf->lock);
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int nfp_pcie_sriov_configure(struct pci_dev *pdev, int num_vfs)
|
static int nfp_pcie_sriov_configure(struct pci_dev *pdev, int num_vfs)
|
||||||
{
|
{
|
||||||
if (num_vfs == 0)
|
if (num_vfs == 0)
|
||||||
|
@ -471,11 +465,11 @@ static void nfp_pci_remove(struct pci_dev *pdev)
|
||||||
|
|
||||||
devlink = priv_to_devlink(pf);
|
devlink = priv_to_devlink(pf);
|
||||||
|
|
||||||
|
nfp_net_pci_remove(pf);
|
||||||
|
|
||||||
nfp_pcie_sriov_disable(pdev);
|
nfp_pcie_sriov_disable(pdev);
|
||||||
pci_sriov_set_totalvfs(pf->pdev, 0);
|
pci_sriov_set_totalvfs(pf->pdev, 0);
|
||||||
|
|
||||||
nfp_net_pci_remove(pf);
|
|
||||||
|
|
||||||
devlink_unregister(devlink);
|
devlink_unregister(devlink);
|
||||||
|
|
||||||
kfree(pf->rtbl);
|
kfree(pf->rtbl);
|
||||||
|
|
|
@ -488,8 +488,16 @@ static int nfp_net_pf_app_start(struct nfp_pf *pf)
|
||||||
if (err)
|
if (err)
|
||||||
goto err_ctrl_stop;
|
goto err_ctrl_stop;
|
||||||
|
|
||||||
|
if (pf->num_vfs) {
|
||||||
|
err = nfp_app_sriov_enable(pf->app, pf->num_vfs);
|
||||||
|
if (err)
|
||||||
|
goto err_app_stop;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
err_app_stop:
|
||||||
|
nfp_app_stop(pf->app);
|
||||||
err_ctrl_stop:
|
err_ctrl_stop:
|
||||||
nfp_net_pf_app_stop_ctrl(pf);
|
nfp_net_pf_app_stop_ctrl(pf);
|
||||||
return err;
|
return err;
|
||||||
|
@ -497,6 +505,8 @@ err_ctrl_stop:
|
||||||
|
|
||||||
static void nfp_net_pf_app_stop(struct nfp_pf *pf)
|
static void nfp_net_pf_app_stop(struct nfp_pf *pf)
|
||||||
{
|
{
|
||||||
|
if (pf->num_vfs)
|
||||||
|
nfp_app_sriov_disable(pf->app);
|
||||||
nfp_app_stop(pf->app);
|
nfp_app_stop(pf->app);
|
||||||
nfp_net_pf_app_stop_ctrl(pf);
|
nfp_net_pf_app_stop_ctrl(pf);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue