nfp: don't hold PF lock while enabling SR-IOV
Enabling SR-IOV VFs will cause the PCI subsystem to schedule a work and flush its workqueue. Since the nfp driver schedules its own work we can't enable VFs while holding driver load. Commit6d48ceb27a
("nfp: allocate a private workqueue for driver work") tried to avoid this deadlock by creating a separate workqueue. Unfortunately, due to the architecture of workqueue subsystem this does not guarantee a separate thread of execution. Luckily we can simply take pci_enable_sriov() from under the driver lock. Take pci_disable_sriov() from under the lock too for symmetry. Fixes:6d48ceb27a
("nfp: allocate a private workqueue for driver work") 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
2f19f50e0f
commit
d6e1ab9ea3
|
@ -98,21 +98,20 @@ static int nfp_pcie_sriov_enable(struct pci_dev *pdev, int num_vfs)
|
||||||
struct nfp_pf *pf = pci_get_drvdata(pdev);
|
struct nfp_pf *pf = pci_get_drvdata(pdev);
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
mutex_lock(&pf->lock);
|
|
||||||
|
|
||||||
if (num_vfs > pf->limit_vfs) {
|
if (num_vfs > pf->limit_vfs) {
|
||||||
nfp_info(pf->cpp, "Firmware limits number of VFs to %u\n",
|
nfp_info(pf->cpp, "Firmware limits number of VFs to %u\n",
|
||||||
pf->limit_vfs);
|
pf->limit_vfs);
|
||||||
err = -EINVAL;
|
return -EINVAL;
|
||||||
goto err_unlock;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = pci_enable_sriov(pdev, num_vfs);
|
err = pci_enable_sriov(pdev, num_vfs);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_warn(&pdev->dev, "Failed to enable PCI SR-IOV: %d\n", err);
|
dev_warn(&pdev->dev, "Failed to enable PCI SR-IOV: %d\n", err);
|
||||||
goto err_unlock;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mutex_lock(&pf->lock);
|
||||||
|
|
||||||
err = nfp_app_sriov_enable(pf->app, num_vfs);
|
err = nfp_app_sriov_enable(pf->app, num_vfs);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_warn(&pdev->dev,
|
dev_warn(&pdev->dev,
|
||||||
|
@ -129,9 +128,8 @@ static int nfp_pcie_sriov_enable(struct pci_dev *pdev, int num_vfs)
|
||||||
return num_vfs;
|
return num_vfs;
|
||||||
|
|
||||||
err_sriov_disable:
|
err_sriov_disable:
|
||||||
pci_disable_sriov(pdev);
|
|
||||||
err_unlock:
|
|
||||||
mutex_unlock(&pf->lock);
|
mutex_unlock(&pf->lock);
|
||||||
|
pci_disable_sriov(pdev);
|
||||||
return err;
|
return err;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -158,10 +156,10 @@ static int nfp_pcie_sriov_disable(struct pci_dev *pdev)
|
||||||
|
|
||||||
pf->num_vfs = 0;
|
pf->num_vfs = 0;
|
||||||
|
|
||||||
|
mutex_unlock(&pf->lock);
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue