Commit 995df527 authored by Wei Yang's avatar Wei Yang Committed by Benjamin Herrenschmidt

PCI: Add pcibios_sriov_enable() and pcibios_sriov_disable()

VFs are dynamically created when a driver enables them.  On some platforms,
like PowerNV, special resources are necessary to enable VFs.

Add platform hooks for enabling and disabling VFs.
Signed-off-by: default avatarWei Yang <weiyang@linux.vnet.ibm.com>
Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent b07579c0
...@@ -220,6 +220,11 @@ static void virtfn_remove(struct pci_dev *dev, int id, int reset) ...@@ -220,6 +220,11 @@ static void virtfn_remove(struct pci_dev *dev, int id, int reset)
pci_dev_put(dev); pci_dev_put(dev);
} }
int __weak pcibios_sriov_enable(struct pci_dev *pdev, u16 num_vfs)
{
return 0;
}
static int sriov_enable(struct pci_dev *dev, int nr_virtfn) static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
{ {
int rc; int rc;
...@@ -231,6 +236,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) ...@@ -231,6 +236,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
struct pci_sriov *iov = dev->sriov; struct pci_sriov *iov = dev->sriov;
int bars = 0; int bars = 0;
int bus; int bus;
int retval;
if (!nr_virtfn) if (!nr_virtfn)
return 0; return 0;
...@@ -307,6 +313,12 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) ...@@ -307,6 +313,12 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
if (nr_virtfn < initial) if (nr_virtfn < initial)
initial = nr_virtfn; initial = nr_virtfn;
if ((retval = pcibios_sriov_enable(dev, initial))) {
dev_err(&dev->dev, "failure %d from pcibios_sriov_enable()\n",
retval);
return retval;
}
for (i = 0; i < initial; i++) { for (i = 0; i < initial; i++) {
rc = virtfn_add(dev, i, 0); rc = virtfn_add(dev, i, 0);
if (rc) if (rc)
...@@ -335,6 +347,11 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) ...@@ -335,6 +347,11 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
return rc; return rc;
} }
int __weak pcibios_sriov_disable(struct pci_dev *pdev)
{
return 0;
}
static void sriov_disable(struct pci_dev *dev) static void sriov_disable(struct pci_dev *dev)
{ {
int i; int i;
...@@ -346,6 +363,8 @@ static void sriov_disable(struct pci_dev *dev) ...@@ -346,6 +363,8 @@ static void sriov_disable(struct pci_dev *dev)
for (i = 0; i < iov->num_VFs; i++) for (i = 0; i < iov->num_VFs; i++)
virtfn_remove(dev, i, 0); virtfn_remove(dev, i, 0);
pcibios_sriov_disable(dev);
iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE); iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE);
pci_cfg_access_lock(dev); pci_cfg_access_lock(dev);
pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl); pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl);
......
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