diff options
author | Ram Pai <linuxram@us.ibm.com> | 2011-11-05 22:33:10 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2011-12-05 13:30:22 -0500 |
commit | bbef98ab0f019f1b0c25c1acdf1683c68933d41b (patch) | |
tree | 07123873f64c4a61fef7c98a4744d4cad852c345 /drivers/pci/iov.c | |
parent | 8e8da023f5af71662867729db5547dc54786093c (diff) |
PCI: defer enablement of SRIOV BARS
All the PCI BARs of a device are enabled when the device is enabled
using pci_enable_device(). This unnecessarily enables SRIOV BARs of the
device.
On some platforms, which do not support SRIOV as yet, the
pci_enable_device() fails to enable the device if its SRIOV BARs are not
allocated resources correctly.
The following patch fixes the above problem. The SRIOV BARs are now
enabled when IOV capability of the device is enabled in sriov_enable().
NOTE: Note, there is subtle change in the pci_enable_device() API. Any
driver that depends on SRIOV BARS to be enabled in pci_enable_device()
can fail.
The patch has been touch tested on power and x86 platform.
Tested-by: Michael Wang <wangyun@linux.vnet.ibm.com>
Signed-off-by: Ram Pai <linuxram@us.ibm.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/iov.c')
-rw-r--r-- | drivers/pci/iov.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index b82c155d7b37..1969a3ee3058 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c | |||
@@ -283,6 +283,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) | |||
283 | struct resource *res; | 283 | struct resource *res; |
284 | struct pci_dev *pdev; | 284 | struct pci_dev *pdev; |
285 | struct pci_sriov *iov = dev->sriov; | 285 | struct pci_sriov *iov = dev->sriov; |
286 | int bars = 0; | ||
286 | 287 | ||
287 | if (!nr_virtfn) | 288 | if (!nr_virtfn) |
288 | return 0; | 289 | return 0; |
@@ -307,6 +308,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) | |||
307 | 308 | ||
308 | nres = 0; | 309 | nres = 0; |
309 | for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) { | 310 | for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) { |
311 | bars |= (1 << (i + PCI_IOV_RESOURCES)); | ||
310 | res = dev->resource + PCI_IOV_RESOURCES + i; | 312 | res = dev->resource + PCI_IOV_RESOURCES + i; |
311 | if (res->parent) | 313 | if (res->parent) |
312 | nres++; | 314 | nres++; |
@@ -324,6 +326,11 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) | |||
324 | return -ENOMEM; | 326 | return -ENOMEM; |
325 | } | 327 | } |
326 | 328 | ||
329 | if (pci_enable_resources(dev, bars)) { | ||
330 | dev_err(&dev->dev, "SR-IOV: IOV BARS not allocated\n"); | ||
331 | return -ENOMEM; | ||
332 | } | ||
333 | |||
327 | if (iov->link != dev->devfn) { | 334 | if (iov->link != dev->devfn) { |
328 | pdev = pci_get_slot(dev->bus, iov->link); | 335 | pdev = pci_get_slot(dev->bus, iov->link); |
329 | if (!pdev) | 336 | if (!pdev) |