mirror of
https://github.com/fail0verflow/switch-linux.git
synced 2025-05-04 02:34:21 -04:00
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>
This commit is contained in:
parent
c83bd900aa
commit
3cedcc3621
1 changed files with 8 additions and 2 deletions
|
@ -343,9 +343,15 @@ int pci_enable_resources(struct pci_dev *dev, int mask)
|
||||||
(!(r->flags & IORESOURCE_ROM_ENABLE)))
|
(!(r->flags & IORESOURCE_ROM_ENABLE)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (r->flags & IORESOURCE_UNSET) {
|
||||||
|
dev_err(&dev->dev, "can't enable device: BAR %d %pR not assigned\n",
|
||||||
|
i, r);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!r->parent) {
|
if (!r->parent) {
|
||||||
dev_err(&dev->dev, "device not available "
|
dev_err(&dev->dev, "can't enable device: BAR %d %pR not claimed\n",
|
||||||
"(can't reserve %pR)\n", r);
|
i, r);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue