Commit c23b6135 authored by Alexander Duyck's avatar Alexander Duyck Committed by Bjorn Helgaas

PCI: Fix sriov_enable() error path for pcibios_enable_sriov() failures

Disable VFs if pcibios_enable_sriov() fails, just like we do for other
errors in sriov_enable().  Call pcibios_sriov_disable() if virtfn_add()
fails.

[bhelgaas: changelog, split to separate patch for reviewability]
Fixes: 995df527 ("PCI: Add pcibios_sriov_enable() and pcibios_sriov_disable()")
Signed-off-by: default avatarAlexander Duyck <aduyck@mirantis.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: default avatarWei Yang <weiyang@linux.vnet.ibm.com>
parent b3908644
...@@ -246,7 +246,6 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) ...@@ -246,7 +246,6 @@ 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;
...@@ -315,10 +314,10 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) ...@@ -315,10 +314,10 @@ 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))) { rc = pcibios_sriov_enable(dev, initial);
dev_err(&dev->dev, "failure %d from pcibios_sriov_enable()\n", if (rc) {
retval); dev_err(&dev->dev, "failure %d from pcibios_sriov_enable()\n", rc);
return retval; goto err_pcibios;
} }
for (i = 0; i < initial; i++) { for (i = 0; i < initial; i++) {
...@@ -336,6 +335,8 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) ...@@ -336,6 +335,8 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
while (i--) while (i--)
virtfn_remove(dev, i, 0); virtfn_remove(dev, i, 0);
pcibios_sriov_disable(dev);
err_pcibios:
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