aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2014-02-26 13:26:00 -0500
committerBjorn Helgaas <bhelgaas@google.com>2014-03-19 17:00:14 -0400
commit3cedcc3621289d41bd21c5dbe0b886d57c83a1ea (patch)
treea746035791d4abbd0b9135e8e4bf46890799f6f1 /drivers
parentc83bd900aac38552b0d903588bbb084d3b26fe71 (diff)
PCI: Don't enable decoding if BAR hasn't been assigned an address
Don't enable memory or I/O decoding if we haven't assigned or claimed the BAR's resource. If we enable decoding for a BAR that hasn't been assigned an address, we'll likely cause bus conflicts. This declines to enable decoding for resources with IORESOURCE_UNSET. Note that drivers can use pci_enable_device_io() or pci_enable_device_mem() if they only care about specific types of BARs. In that case, we don't bother checking whether the corresponding resources are assigned or claimed. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/setup-res.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 6e443135ba24..7eed671d5586 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -343,9 +343,15 @@ int pci_enable_resources(struct pci_dev *dev, int mask)
343 (!(r->flags & IORESOURCE_ROM_ENABLE))) 343 (!(r->flags & IORESOURCE_ROM_ENABLE)))
344 continue; 344 continue;
345 345
346 if (r->flags & IORESOURCE_UNSET) {
347 dev_err(&dev->dev, "can't enable device: BAR %d %pR not assigned\n",
348 i, r);
349 return -EINVAL;
350 }
351
346 if (!r->parent) { 352 if (!r->parent) {
347 dev_err(&dev->dev, "device not available " 353 dev_err(&dev->dev, "can't enable device: BAR %d %pR not claimed\n",
348 "(can't reserve %pR)\n", r); 354 i, r);
349 return -EINVAL; 355 return -EINVAL;
350 } 356 }
351 357