Commit 6d48ceb2 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: allocate a private workqueue for driver work

Since we grab pf->lock around pci_enable_sriov() we can no longer
safely queue work which may also grab that lock onto system workqueue.
pci_enable_sriov() will flush system workqueue as part to wait for VF
probing.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarSimon Horman <simon.horman@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e3f28473
...@@ -376,6 +376,12 @@ static int nfp_pci_probe(struct pci_dev *pdev, ...@@ -376,6 +376,12 @@ static int nfp_pci_probe(struct pci_dev *pdev,
pci_set_drvdata(pdev, pf); pci_set_drvdata(pdev, pf);
pf->pdev = pdev; pf->pdev = pdev;
pf->wq = alloc_workqueue("nfp-%s", 0, 2, pci_name(pdev));
if (!pf->wq) {
err = -ENOMEM;
goto err_pci_priv_unset;
}
pf->cpp = nfp_cpp_from_nfp6000_pcie(pdev); pf->cpp = nfp_cpp_from_nfp6000_pcie(pdev);
if (IS_ERR_OR_NULL(pf->cpp)) { if (IS_ERR_OR_NULL(pf->cpp)) {
err = PTR_ERR(pf->cpp); err = PTR_ERR(pf->cpp);
...@@ -445,6 +451,8 @@ static int nfp_pci_probe(struct pci_dev *pdev, ...@@ -445,6 +451,8 @@ static int nfp_pci_probe(struct pci_dev *pdev,
kfree(pf->hwinfo); kfree(pf->hwinfo);
nfp_cpp_free(pf->cpp); nfp_cpp_free(pf->cpp);
err_disable_msix: err_disable_msix:
destroy_workqueue(pf->wq);
err_pci_priv_unset:
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
mutex_destroy(&pf->lock); mutex_destroy(&pf->lock);
devlink_free(devlink); devlink_free(devlink);
...@@ -477,6 +485,7 @@ static void nfp_pci_remove(struct pci_dev *pdev) ...@@ -477,6 +485,7 @@ static void nfp_pci_remove(struct pci_dev *pdev)
if (pf->fw_loaded) if (pf->fw_loaded)
nfp_fw_unload(pf); nfp_fw_unload(pf);
destroy_workqueue(pf->wq);
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
kfree(pf->hwinfo); kfree(pf->hwinfo);
nfp_cpp_free(pf->cpp); nfp_cpp_free(pf->cpp);
......
...@@ -89,6 +89,7 @@ struct nfp_rtsym_table; ...@@ -89,6 +89,7 @@ struct nfp_rtsym_table;
* @num_vnics: Number of vNICs spawned * @num_vnics: Number of vNICs spawned
* @vnics: Linked list of vNIC structures (struct nfp_net) * @vnics: Linked list of vNIC structures (struct nfp_net)
* @ports: Linked list of port structures (struct nfp_port) * @ports: Linked list of port structures (struct nfp_port)
* @wq: Workqueue for running works which need to grab @lock
* @port_refresh_work: Work entry for taking netdevs out * @port_refresh_work: Work entry for taking netdevs out
* @lock: Protects all fields which may change after probe * @lock: Protects all fields which may change after probe
*/ */
...@@ -131,7 +132,10 @@ struct nfp_pf { ...@@ -131,7 +132,10 @@ struct nfp_pf {
struct list_head vnics; struct list_head vnics;
struct list_head ports; struct list_head ports;
struct workqueue_struct *wq;
struct work_struct port_refresh_work; struct work_struct port_refresh_work;
struct mutex lock; struct mutex lock;
}; };
......
...@@ -682,7 +682,7 @@ void nfp_net_refresh_port_table(struct nfp_port *port) ...@@ -682,7 +682,7 @@ void nfp_net_refresh_port_table(struct nfp_port *port)
set_bit(NFP_PORT_CHANGED, &port->flags); set_bit(NFP_PORT_CHANGED, &port->flags);
schedule_work(&pf->port_refresh_work); queue_work(pf->wq, &pf->port_refresh_work);
} }
int nfp_net_refresh_eth_port(struct nfp_port *port) int nfp_net_refresh_eth_port(struct nfp_port *port)
......
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