VFs are dynamically created/released when driver enable them. On some platforms, like PowerNV, special resources are necessary to enable VFs. This patch adds two hooks for platform initialization before creating the VFs. Signed-off-by: Wei Yang <weiyang@xxxxxxxxxxxxxxxxxx> --- drivers/pci/iov.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index e76d1a0..933d8cc 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -213,6 +213,11 @@ static void virtfn_remove(struct pci_dev *dev, int id, int reset) pci_dev_put(dev); } +int __weak pcibios_sriov_enable(struct pci_dev *pdev, u16 vf_num) +{ + return 0; +} + static int sriov_enable(struct pci_dev *dev, int nr_virtfn) { int rc; @@ -223,6 +228,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) struct pci_dev *pdev; struct pci_sriov *iov = dev->sriov; int bars = 0; + int retval; if (!nr_virtfn) return 0; @@ -297,6 +303,12 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) if (nr_virtfn < initial) initial = nr_virtfn; + if ((retval = pcibios_sriov_enable(dev, initial))) { + dev_err(&dev->dev, "Failure %d from pcibios_sriov_setup()\n", + retval); + return retval; + } + for (i = 0; i < initial; i++) { rc = virtfn_add(dev, i, 0); if (rc) @@ -325,6 +337,11 @@ failed: return rc; } +int __weak pcibios_sriov_disable(struct pci_dev *pdev, u16 vf_num) +{ + return 0; +} + static void sriov_disable(struct pci_dev *dev) { int i; @@ -336,6 +353,8 @@ static void sriov_disable(struct pci_dev *dev) for (i = 0; i < iov->num_VFs; i++) virtfn_remove(dev, i, 0); + pcibios_sriov_disable(dev, iov->num_VFs); + iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE); pci_cfg_access_lock(dev); pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html