diff options
-rw-r--r-- | drivers/pci/iov.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 5643a1011e23..64c46925c62d 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c | |||
@@ -220,6 +220,11 @@ static void virtfn_remove(struct pci_dev *dev, int id, int reset) | |||
220 | pci_dev_put(dev); | 220 | pci_dev_put(dev); |
221 | } | 221 | } |
222 | 222 | ||
223 | int __weak pcibios_sriov_enable(struct pci_dev *pdev, u16 num_vfs) | ||
224 | { | ||
225 | return 0; | ||
226 | } | ||
227 | |||
223 | static int sriov_enable(struct pci_dev *dev, int nr_virtfn) | 228 | static int sriov_enable(struct pci_dev *dev, int nr_virtfn) |
224 | { | 229 | { |
225 | int rc; | 230 | int rc; |
@@ -231,6 +236,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) | |||
231 | struct pci_sriov *iov = dev->sriov; | 236 | struct pci_sriov *iov = dev->sriov; |
232 | int bars = 0; | 237 | int bars = 0; |
233 | int bus; | 238 | int bus; |
239 | int retval; | ||
234 | 240 | ||
235 | if (!nr_virtfn) | 241 | if (!nr_virtfn) |
236 | return 0; | 242 | return 0; |
@@ -307,6 +313,12 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) | |||
307 | if (nr_virtfn < initial) | 313 | if (nr_virtfn < initial) |
308 | initial = nr_virtfn; | 314 | initial = nr_virtfn; |
309 | 315 | ||
316 | if ((retval = pcibios_sriov_enable(dev, initial))) { | ||
317 | dev_err(&dev->dev, "failure %d from pcibios_sriov_enable()\n", | ||
318 | retval); | ||
319 | return retval; | ||
320 | } | ||
321 | |||
310 | for (i = 0; i < initial; i++) { | 322 | for (i = 0; i < initial; i++) { |
311 | rc = virtfn_add(dev, i, 0); | 323 | rc = virtfn_add(dev, i, 0); |
312 | if (rc) | 324 | if (rc) |
@@ -335,6 +347,11 @@ failed: | |||
335 | return rc; | 347 | return rc; |
336 | } | 348 | } |
337 | 349 | ||
350 | int __weak pcibios_sriov_disable(struct pci_dev *pdev) | ||
351 | { | ||
352 | return 0; | ||
353 | } | ||
354 | |||
338 | static void sriov_disable(struct pci_dev *dev) | 355 | static void sriov_disable(struct pci_dev *dev) |
339 | { | 356 | { |
340 | int i; | 357 | int i; |
@@ -346,6 +363,8 @@ static void sriov_disable(struct pci_dev *dev) | |||
346 | for (i = 0; i < iov->num_VFs; i++) | 363 | for (i = 0; i < iov->num_VFs; i++) |
347 | virtfn_remove(dev, i, 0); | 364 | virtfn_remove(dev, i, 0); |
348 | 365 | ||
366 | pcibios_sriov_disable(dev); | ||
367 | |||
349 | iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE); | 368 | iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE); |
350 | pci_cfg_access_lock(dev); | 369 | pci_cfg_access_lock(dev); |
351 | pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl); | 370 | pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl); |