aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci.c
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2014-03-19 17:11:19 -0400
committerBjorn Helgaas <bhelgaas@google.com>2014-03-19 17:11:19 -0400
commit30723cbf6f7aec2ab4810bdc4bf12c5749a09e33 (patch)
tree840833435357419595fee44b2a06f9864f1458c9 /drivers/pci/pci.c
parent91b4adc983d8e9975bc677c2b8395631edf7b92d (diff)
parentf2e6027b816df3326d3f40d6ce55539a2f381529 (diff)
Merge branch 'pci/resource' into next
* pci/resource: (26 commits) Revert "[PATCH] Insert GART region into resource map" PCI: Log IDE resource quirk in dmesg PCI: Change pci_bus_alloc_resource() type_mask to unsigned long PCI: Check all IORESOURCE_TYPE_BITS in pci_bus_alloc_from_region() resources: Set type in __request_region() PCI: Don't check resource_size() in pci_bus_alloc_resource() s390/PCI: Use generic pci_enable_resources() tile PCI RC: Use default pcibios_enable_device() sparc/PCI: Use default pcibios_enable_device() (Leon only) sh/PCI: Use default pcibios_enable_device() microblaze/PCI: Use default pcibios_enable_device() alpha/PCI: Use default pcibios_enable_device() PCI: Add "weak" generic pcibios_enable_device() implementation PCI: Don't enable decoding if BAR hasn't been assigned an address PCI: Mark 64-bit resource as IORESOURCE_UNSET if we only support 32-bit PCI: Don't try to claim IORESOURCE_UNSET resources PCI: Check IORESOURCE_UNSET before updating BAR PCI: Don't clear IORESOURCE_UNSET when updating BAR PCI: Mark resources as IORESOURCE_UNSET if we can't assign them PCI: Remove pci_find_parent_resource() use for allocation ...
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r--drivers/pci/pci.c46
1 files changed, 30 insertions, 16 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 505fbb670d6a..7325d43bf030 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -401,33 +401,40 @@ EXPORT_SYMBOL_GPL(pci_find_ht_capability);
401 * @res: child resource record for which parent is sought 401 * @res: child resource record for which parent is sought
402 * 402 *
403 * For given resource region of given device, return the resource 403 * For given resource region of given device, return the resource
404 * region of parent bus the given region is contained in or where 404 * region of parent bus the given region is contained in.
405 * it should be allocated from.
406 */ 405 */
407struct resource * 406struct resource *
408pci_find_parent_resource(const struct pci_dev *dev, struct resource *res) 407pci_find_parent_resource(const struct pci_dev *dev, struct resource *res)
409{ 408{
410 const struct pci_bus *bus = dev->bus; 409 const struct pci_bus *bus = dev->bus;
410 struct resource *r;
411 int i; 411 int i;
412 struct resource *best = NULL, *r;
413 412
414 pci_bus_for_each_resource(bus, r, i) { 413 pci_bus_for_each_resource(bus, r, i) {
415 if (!r) 414 if (!r)
416 continue; 415 continue;
417 if (res->start && !(res->start >= r->start && res->end <= r->end)) 416 if (res->start && resource_contains(r, res)) {
418 continue; /* Not contained */ 417
419 if ((res->flags ^ r->flags) & (IORESOURCE_IO | IORESOURCE_MEM)) 418 /*
420 continue; /* Wrong type */ 419 * If the window is prefetchable but the BAR is
421 if (!((res->flags ^ r->flags) & IORESOURCE_PREFETCH)) 420 * not, the allocator made a mistake.
422 return r; /* Exact match */ 421 */
423 /* We can't insert a non-prefetch resource inside a prefetchable parent .. */ 422 if (r->flags & IORESOURCE_PREFETCH &&
424 if (r->flags & IORESOURCE_PREFETCH) 423 !(res->flags & IORESOURCE_PREFETCH))
425 continue; 424 return NULL;
426 /* .. but we can put a prefetchable resource inside a non-prefetchable one */ 425
427 if (!best) 426 /*
428 best = r; 427 * If we're below a transparent bridge, there may
428 * be both a positively-decoded aperture and a
429 * subtractively-decoded region that contain the BAR.
430 * We want the positively-decoded one, so this depends
431 * on pci_bus_for_each_resource() giving us those
432 * first.
433 */
434 return r;
435 }
429 } 436 }
430 return best; 437 return NULL;
431} 438}
432 439
433/** 440/**
@@ -1178,6 +1185,11 @@ int pci_load_and_free_saved_state(struct pci_dev *dev,
1178} 1185}
1179EXPORT_SYMBOL_GPL(pci_load_and_free_saved_state); 1186EXPORT_SYMBOL_GPL(pci_load_and_free_saved_state);
1180 1187
1188int __weak pcibios_enable_device(struct pci_dev *dev, int bars)
1189{
1190 return pci_enable_resources(dev, bars);
1191}
1192
1181static int do_pci_enable_device(struct pci_dev *dev, int bars) 1193static int do_pci_enable_device(struct pci_dev *dev, int bars)
1182{ 1194{
1183 int err; 1195 int err;
@@ -4262,6 +4274,7 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
4262 "Rounding up size of resource #%d to %#llx.\n", 4274 "Rounding up size of resource #%d to %#llx.\n",
4263 i, (unsigned long long)size); 4275 i, (unsigned long long)size);
4264 } 4276 }
4277 r->flags |= IORESOURCE_UNSET;
4265 r->end = size - 1; 4278 r->end = size - 1;
4266 r->start = 0; 4279 r->start = 0;
4267 } 4280 }
@@ -4275,6 +4288,7 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
4275 r = &dev->resource[i]; 4288 r = &dev->resource[i];
4276 if (!(r->flags & IORESOURCE_MEM)) 4289 if (!(r->flags & IORESOURCE_MEM))
4277 continue; 4290 continue;
4291 r->flags |= IORESOURCE_UNSET;
4278 r->end = resource_size(r) - 1; 4292 r->end = resource_size(r) - 1;
4279 r->start = 0; 4293 r->start = 0;
4280 } 4294 }