nvme/pci: Provide SR-IOV support
PATCH 1/1 nvme/pci: Provide SR-IOV support
This registers a standard boiler-plate sr-iov callback for nvme.
--- drivers/nvme/host/pci.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/nvme/host/pci.c +21 -0
@@ -2033,6 +2033,26 @@ static void nvme_remove(struct pci_dev *pdev)nvme_put_ctrl (&dev->ctrl); } +static int nvme_pci_sriov_configure (struct pci_dev *pdev,int numvfs) +{ +int ret =0 ; + +if (!pdev->is_physfn) +return -EPERM ; + +if (numvfs ==0 ) { +if (pci_vfs_assigned (pdev)) { +dev_warn (&pdev->dev, +"Cannot disable SR-IOV VFs while assigned\n" ); +return -EPERM ; + } +pci_disable_sriov (pdev); + }else + ret =pci_enable_sriov (pdev, numvfs); + +return ret ? ret : numvfs; +} +#ifdef CONFIG_PM_SLEEP static int nvme_suspend (struct device *dev) {
@@ -2127,6 +2147,7 @@ static struct pci_driver nvme_driver = { .driver = { .pm = &nvme_dev_pm_ops, }, + .sriov_configure = nvme_pci_sriov_configure, .err_handler = &nvme_err_handler, };
Signature · 1 line
2.7.2
PATCH 1/1 nvme/pci: Provide SR-IOV support
Quoted 1 line · Keith Busch
This registers a standard boiler-plate sr-iov callback for nvme.
No real reason not to add it, but..
drivers/nvme/host/pci.c static void nvme_remove(struct pci_dev *pdev) · line 2041
Quoted 6 lines
drivers/nvme/host/pci.c +6
-0+static int nvme_pci_sriov_configure (struct pci_dev *pdev,int numvfs) +{ +int ret =0 ; + +if (!pdev->is_physfn) +return -EPERM ;
pci_enable_sriov / pci_disable_sriov already check this.
drivers/nvme/host/pci.c static void nvme_remove(struct pci_dev *pdev) · line 2048
Quoted 6 lines
drivers/nvme/host/pci.c +6
-0+if (numvfs ==0 ) { +if (pci_vfs_assigned (pdev)) { +dev_warn (&pdev->dev, +"Cannot disable SR-IOV VFs while assigned\n" ); +return -EPERM ; + }
And pci_disable_sriov really should check this.
drivers/nvme/host/pci.c static void nvme_remove(struct pci_dev *pdev) · line 2051
Quoted 3 lines
drivers/nvme/host/pci.c +3
-0+pci_disable_sriov (pdev); + }else + ret =pci_enable_sriov (pdev, numvfs);
And these calls really should be done in common code. At that point there will be a whole lot less driver involvement with SR-IOV which shouldn't exist, and we can split the callback into two for enable vs disable instead of the overload that each driver then needs to demultiplex.
I guess I can't just burden the second half on you, but at least removing the first check and moving the second to the core would seem like a good start.