aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Duyck <aduyck@mirantis.com>2015-10-29 17:21:20 -0400
committerBjorn Helgaas <bhelgaas@google.com>2015-10-30 16:15:02 -0400
commitc23b613507b8fa10e1839fb5a42e1b0318bf1d27 (patch)
treeff0c75027f5d1d69dc524730fb41c23af52c0f57
parentb390864482924a21f8d7e25636d0140de93fba7e (diff)
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: 995df527f399 ("PCI: Add pcibios_sriov_enable() and pcibios_sriov_disable()") Signed-off-by: Alexander Duyck <aduyck@mirantis.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Wei Yang <weiyang@linux.vnet.ibm.com>
-rw-r--r--drivers/pci/iov.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 24428d5f60cd..bd1c4faedea2 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -246,7 +246,6 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
246 struct pci_sriov *iov = dev->sriov; 246 struct pci_sriov *iov = dev->sriov;
247 int bars = 0; 247 int bars = 0;
248 int bus; 248 int bus;
249 int retval;
250 249
251 if (!nr_virtfn) 250 if (!nr_virtfn)
252 return 0; 251 return 0;
@@ -315,10 +314,10 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
315 if (nr_virtfn < initial) 314 if (nr_virtfn < initial)
316 initial = nr_virtfn; 315 initial = nr_virtfn;
317 316
318 if ((retval = pcibios_sriov_enable(dev, initial))) { 317 rc = pcibios_sriov_enable(dev, initial);
319 dev_err(&dev->dev, "failure %d from pcibios_sriov_enable()\n", 318 if (rc) {
320 retval); 319 dev_err(&dev->dev, "failure %d from pcibios_sriov_enable()\n", rc);
321 return retval; 320 goto err_pcibios;
322 } 321 }
323 322
324 for (i = 0; i < initial; i++) { 323 for (i = 0; i < initial; i++) {
@@ -336,6 +335,8 @@ failed:
336 while (i--) 335 while (i--)
337 virtfn_remove(dev, i, 0); 336 virtfn_remove(dev, i, 0);
338 337
338 pcibios_sriov_disable(dev);
339err_pcibios:
339 iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE); 340 iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE);
340 pci_cfg_access_lock(dev); 341 pci_cfg_access_lock(dev);
341 pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl); 342 pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl);