Lines Matching +full:non +full:- +full:prefetchable
1 // SPDX-License-Identifier: GPL-2.0
11 * PCI-PCI bridges cleanup, sorted resource allocation.
14 * tighter packing. Prefetchable range support.
46 list_del(&dev_res->list); in free_list()
52 * add_to_list() - add a new resource tracker to the list
68 return -ENOMEM; in add_to_list()
70 tmp->res = res; in add_to_list()
71 tmp->dev = dev; in add_to_list()
72 tmp->start = res->start; in add_to_list()
73 tmp->end = res->end; in add_to_list()
74 tmp->flags = res->flags; in add_to_list()
75 tmp->add_size = add_size; in add_to_list()
76 tmp->min_align = min_align; in add_to_list()
78 list_add(&tmp->list, head); in add_to_list()
89 if (dev_res->res == res) { in remove_from_list()
90 list_del(&dev_res->list); in remove_from_list()
103 if (dev_res->res == res) in res_to_dev_res()
116 return dev_res ? dev_res->add_size : 0; in get_res_add_size()
125 return dev_res ? dev_res->min_align : 0; in get_res_add_align()
140 r = &dev->resource[i]; in pdev_sort_resources()
142 if (r->flags & IORESOURCE_PCI_FIXED) in pdev_sort_resources()
145 if (!(r->flags) || r->parent) in pdev_sort_resources()
158 tmp->res = r; in pdev_sort_resources()
159 tmp->dev = dev; in pdev_sort_resources()
166 align = pci_resource_alignment(dev_res->dev, in pdev_sort_resources()
167 dev_res->res); in pdev_sort_resources()
170 n = &dev_res->list; in pdev_sort_resources()
175 list_add_tail(&tmp->list, n); in pdev_sort_resources()
182 u16 class = dev->class >> 8; in __dev_sort_resources()
201 res->start = 0; in reset_resource()
202 res->end = 0; in reset_resource()
203 res->flags = 0; in reset_resource()
207 * reassign_resources_sorted() - satisfy any additional resource requests
230 res = add_res->res; in reassign_resources_sorted()
232 if (!res->flags) in reassign_resources_sorted()
237 if (dev_res->res == res) { in reassign_resources_sorted()
245 idx = res - &add_res->dev->resource[0]; in reassign_resources_sorted()
246 add_size = add_res->add_size; in reassign_resources_sorted()
247 align = add_res->min_align; in reassign_resources_sorted()
249 res->start = align; in reassign_resources_sorted()
250 res->end = res->start + add_size - 1; in reassign_resources_sorted()
251 if (pci_assign_resource(add_res->dev, idx)) in reassign_resources_sorted()
254 res->flags |= add_res->flags & in reassign_resources_sorted()
256 if (pci_reassign_resource(add_res->dev, idx, in reassign_resources_sorted()
258 pci_printk(KERN_DEBUG, add_res->dev, in reassign_resources_sorted()
264 list_del(&add_res->list); in reassign_resources_sorted()
270 * assign_requested_resources_sorted() - satisfy resource requests
287 res = dev_res->res; in assign_requested_resources_sorted()
288 idx = res - &dev_res->dev->resource[0]; in assign_requested_resources_sorted()
290 pci_assign_resource(dev_res->dev, idx)) { in assign_requested_resources_sorted()
297 (!(res->flags & IORESOURCE_ROM_ENABLE)))) in assign_requested_resources_sorted()
299 dev_res->dev, res, in assign_requested_resources_sorted()
315 mask |= fail_res->flags; in pci_fail_res_type_mask()
319 * as we can allocate pref in non-pref range. in pci_fail_res_type_mask()
320 * Will release all assigned non-pref sibling resources in pci_fail_res_type_mask()
328 if (res->flags & IORESOURCE_IO) in pci_need_to_release()
332 if (res->flags & IORESOURCE_PREFETCH) { in pci_need_to_release()
335 /* count pref if its parent is non-pref */ in pci_need_to_release()
337 !(res->parent->flags & IORESOURCE_PREFETCH)) in pci_need_to_release()
343 if (res->flags & IORESOURCE_MEM) in pci_need_to_release()
368 * if assigned pref mmio's parent is non-pref mmio and there in __assign_resources_sorted()
369 * is non-pref mmio assign fail, will release that assigned in __assign_resources_sorted()
371 * 3. if there is non-pref mmio assign fail or pref mmio in __assign_resources_sorted()
372 * assigned fail, will release assigned non-pref mmio. in __assign_resources_sorted()
387 if (add_to_list(&save_head, dev_res->dev, dev_res->res, 0, 0)) { in __assign_resources_sorted()
395 dev_res->res->end += get_res_add_size(realloc_head, in __assign_resources_sorted()
396 dev_res->res); in __assign_resources_sorted()
400 * 1. bridge resource -- IORESOURCE_STARTALIGN in __assign_resources_sorted()
401 * 2. SR-IOV resource -- IORESOURCE_SIZEALIGN in __assign_resources_sorted()
404 if (!(dev_res->res->flags & IORESOURCE_STARTALIGN)) in __assign_resources_sorted()
407 add_align = get_res_add_align(realloc_head, dev_res->res); in __assign_resources_sorted()
416 if (add_align > dev_res->res->start) { in __assign_resources_sorted()
417 resource_size_t r_size = resource_size(dev_res->res); in __assign_resources_sorted()
419 dev_res->res->start = add_align; in __assign_resources_sorted()
420 dev_res->res->end = add_align + r_size - 1; in __assign_resources_sorted()
423 align = pci_resource_alignment(dev_res2->dev, in __assign_resources_sorted()
424 dev_res2->res); in __assign_resources_sorted()
426 list_move_tail(&dev_res->list, in __assign_resources_sorted()
427 &dev_res2->list); in __assign_resources_sorted()
442 remove_from_list(realloc_head, dev_res->res); in __assign_resources_sorted()
452 if (dev_res->res->parent && in __assign_resources_sorted()
453 !pci_need_to_release(fail_type, dev_res->res)) { in __assign_resources_sorted()
455 remove_from_list(realloc_head, dev_res->res); in __assign_resources_sorted()
456 remove_from_list(&save_head, dev_res->res); in __assign_resources_sorted()
457 list_del(&dev_res->list); in __assign_resources_sorted()
464 if (dev_res->res->parent) in __assign_resources_sorted()
465 release_resource(dev_res->res); in __assign_resources_sorted()
468 struct resource *res = save_res->res; in __assign_resources_sorted()
470 res->start = save_res->start; in __assign_resources_sorted()
471 res->end = save_res->end; in __assign_resources_sorted()
472 res->flags = save_res->flags; in __assign_resources_sorted()
477 /* Satisfy the must-have resource requests */ in __assign_resources_sorted()
505 list_for_each_entry(dev, &bus->devices, bus_list) in pbus_assign_resources_sorted()
513 struct pci_dev *bridge = bus->self; in pci_setup_cardbus()
518 &bus->busn_res); in pci_setup_cardbus()
520 res = bus->resource[0]; in pci_setup_cardbus()
521 pcibios_resource_to_bus(bridge->bus, ®ion, res); in pci_setup_cardbus()
522 if (res->flags & IORESOURCE_IO) { in pci_setup_cardbus()
534 res = bus->resource[1]; in pci_setup_cardbus()
535 pcibios_resource_to_bus(bridge->bus, ®ion, res); in pci_setup_cardbus()
536 if (res->flags & IORESOURCE_IO) { in pci_setup_cardbus()
544 res = bus->resource[2]; in pci_setup_cardbus()
545 pcibios_resource_to_bus(bridge->bus, ®ion, res); in pci_setup_cardbus()
546 if (res->flags & IORESOURCE_MEM) { in pci_setup_cardbus()
554 res = bus->resource[3]; in pci_setup_cardbus()
555 pcibios_resource_to_bus(bridge->bus, ®ion, res); in pci_setup_cardbus()
556 if (res->flags & IORESOURCE_MEM) { in pci_setup_cardbus()
567 PCI-to-PCI Bridge Architecture Specification rev. 1.1 (1998)
573 of bridges which support 32-bit I/O. This update requires two
576 first write. Ditto 64-bit prefetchable MMIO. */
587 if (bridge->io_window_1k) in pci_setup_bridge_io()
591 res = &bridge->resource[PCI_BRIDGE_RESOURCES + 0]; in pci_setup_bridge_io()
592 pcibios_resource_to_bus(bridge->bus, ®ion, res); in pci_setup_bridge_io()
593 if (res->flags & IORESOURCE_IO) { in pci_setup_bridge_io()
621 res = &bridge->resource[PCI_BRIDGE_RESOURCES + 1]; in pci_setup_bridge_mmio()
622 pcibios_resource_to_bus(bridge->bus, ®ion, res); in pci_setup_bridge_mmio()
623 if (res->flags & IORESOURCE_MEM) { in pci_setup_bridge_mmio()
640 If PCI_PREF_BASE_UPPER32 was non-zero, this temporarily in pci_setup_bridge_mmio_pref()
646 res = &bridge->resource[PCI_BRIDGE_RESOURCES + 2]; in pci_setup_bridge_mmio_pref()
647 pcibios_resource_to_bus(bridge->bus, ®ion, res); in pci_setup_bridge_mmio_pref()
648 if (res->flags & IORESOURCE_PREFETCH) { in pci_setup_bridge_mmio_pref()
651 if (res->flags & IORESOURCE_MEM_64) { in pci_setup_bridge_mmio_pref()
668 struct pci_dev *bridge = bus->self; in __pci_setup_bridge()
671 &bus->busn_res); in __pci_setup_bridge()
682 pci_write_config_word(bridge, PCI_BRIDGE_CONTROL, bus->bridge_ctl); in __pci_setup_bridge()
707 if ((bridge->class >> 8) != PCI_CLASS_BRIDGE_PCI) in pci_claim_bridge_resource()
711 return -EINVAL; /* clipping didn't change anything */ in pci_claim_bridge_resource()
713 switch (i - PCI_BRIDGE_RESOURCES) { in pci_claim_bridge_resource()
724 return -EINVAL; in pci_claim_bridge_resource()
730 return -EINVAL; in pci_claim_bridge_resource()
734 prefetchable memory ranges. If not, the respective
735 base/limit registers must be read-only and read as 0. */
738 struct pci_dev *bridge = bus->self; in pci_bridge_check_ranges()
739 struct resource *b_res = &bridge->resource[PCI_BRIDGE_RESOURCES]; in pci_bridge_check_ranges()
743 if (bridge->io_window) in pci_bridge_check_ranges()
746 if (bridge->pref_window) { in pci_bridge_check_ranges()
748 if (bridge->pref_64_window) { in pci_bridge_check_ranges()
758 have non-NULL parent resource). */
768 if (r && (r->flags & type_mask) == type && !r->parent) in find_free_bus_resource()
830 * Per spec, I/O windows are 4K-aligned, but some in window_alignment()
833 if (bus->self->io_window_1k) in window_alignment()
844 * pbus_size_io() - size the io window of a given bus
851 * Sizing the IO windows of the PCI-PCI bridge is trivial,
853 * of non-bridge PCI devices are limited to 256 bytes.
870 list_for_each_entry(dev, &bus->devices, bus_list) { in pbus_size_io()
874 struct resource *r = &dev->resource[i]; in pbus_size_io()
877 if (r->parent || !(r->flags & IORESOURCE_IO)) in pbus_size_io()
882 /* Might be re-aligned for ISA */ in pbus_size_io()
904 if (b_res->start || b_res->end) in pbus_size_io()
905 pci_info(bus->self, "disabling bridge window %pR to %pR (unused)\n", in pbus_size_io()
906 b_res, &bus->busn_res); in pbus_size_io()
907 b_res->flags = 0; in pbus_size_io()
911 b_res->start = min_align; in pbus_size_io()
912 b_res->end = b_res->start + size0 - 1; in pbus_size_io()
913 b_res->flags |= IORESOURCE_STARTALIGN; in pbus_size_io()
915 add_to_list(realloc_head, bus->self, b_res, size1-size0, in pbus_size_io()
917 pci_printk(KERN_DEBUG, bus->self, "bridge window %pR to %pR add_size %llx\n", in pbus_size_io()
918 b_res, &bus->busn_res, in pbus_size_io()
919 (unsigned long long)size1-size0); in pbus_size_io()
946 * pbus_size_mem() - size the memory window of a given bus
960 * Returns -ENOSPC if there's no available bus resource of the desired type.
981 return -ENOSPC; in pbus_size_mem()
987 list_for_each_entry(dev, &bus->devices, bus_list) { in pbus_size_mem()
991 struct resource *r = &dev->resource[i]; in pbus_size_mem()
994 if (r->parent || (r->flags & IORESOURCE_PCI_FIXED) || in pbus_size_mem()
995 ((r->flags & mask) != type && in pbus_size_mem()
996 (r->flags & mask) != type2 && in pbus_size_mem()
997 (r->flags & mask) != type3)) in pbus_size_mem()
1005 r->end = r->start - 1; in pbus_size_mem()
1018 order = __ffs(align) - 20; in pbus_size_mem()
1024 r->flags = 0; in pbus_size_mem()
1044 min_align = max(min_align, window_alignment(bus, b_res->flags)); in pbus_size_mem()
1053 if (b_res->start || b_res->end) in pbus_size_mem()
1054 pci_info(bus->self, "disabling bridge window %pR to %pR (unused)\n", in pbus_size_mem()
1055 b_res, &bus->busn_res); in pbus_size_mem()
1056 b_res->flags = 0; in pbus_size_mem()
1059 b_res->start = min_align; in pbus_size_mem()
1060 b_res->end = size0 + min_align - 1; in pbus_size_mem()
1061 b_res->flags |= IORESOURCE_STARTALIGN; in pbus_size_mem()
1063 add_to_list(realloc_head, bus->self, b_res, size1-size0, add_align); in pbus_size_mem()
1064 pci_printk(KERN_DEBUG, bus->self, "bridge window %pR to %pR add_size %llx add_align %llx\n", in pbus_size_mem()
1065 b_res, &bus->busn_res, in pbus_size_mem()
1066 (unsigned long long) (size1 - size0), in pbus_size_mem()
1074 if (res->flags & IORESOURCE_IO) in pci_cardbus_resource_alignment()
1076 if (res->flags & IORESOURCE_MEM) in pci_cardbus_resource_alignment()
1084 struct pci_dev *bridge = bus->self; in pci_bus_size_cardbus()
1085 struct resource *b_res = &bridge->resource[PCI_BRIDGE_RESOURCES]; in pci_bus_size_cardbus()
1096 b_res[0].end = b_res[0].start + pci_cardbus_io_size - 1; in pci_bus_size_cardbus()
1099 b_res[0].end -= pci_cardbus_io_size; in pci_bus_size_cardbus()
1108 b_res[1].end = b_res[1].start + pci_cardbus_io_size - 1; in pci_bus_size_cardbus()
1111 b_res[1].end -= pci_cardbus_io_size; in pci_bus_size_cardbus()
1126 * Check whether prefetchable memory is supported in pci_bus_size_cardbus()
1139 * If we have prefetchable memory support, allocate in pci_bus_size_cardbus()
1145 b_res[2].end = b_res[2].start + pci_cardbus_mem_size - 1; in pci_bus_size_cardbus()
1149 b_res[2].end -= pci_cardbus_mem_size; in pci_bus_size_cardbus()
1162 b_res[3].end = b_res[3].start + b_res_3_size - 1; in pci_bus_size_cardbus()
1165 b_res[3].end -= b_res_3_size; in pci_bus_size_cardbus()
1182 list_for_each_entry(dev, &bus->devices, bus_list) { in __pci_bus_size_bridges()
1183 struct pci_bus *b = dev->subordinate; in __pci_bus_size_bridges()
1187 switch (dev->class >> 8) { in __pci_bus_size_bridges()
1203 switch (bus->self->class >> 8) { in __pci_bus_size_bridges()
1210 if (bus->self->is_hotplug_bridge) { in __pci_bus_size_bridges()
1220 * If there's a 64-bit prefetchable MMIO window, compute in __pci_bus_size_bridges()
1221 * the size required to put all 64-bit prefetchable in __pci_bus_size_bridges()
1224 b_res = &bus->self->resource[PCI_BRIDGE_RESOURCES]; in __pci_bus_size_bridges()
1235 * If successful, all non-prefetchable resources in __pci_bus_size_bridges()
1236 * and any 32-bit prefetchable resources will go in in __pci_bus_size_bridges()
1237 * the non-prefetchable window. in __pci_bus_size_bridges()
1247 * If there is no 64-bit prefetchable window, compute the in __pci_bus_size_bridges()
1248 * size required to put all prefetchable resources in the in __pci_bus_size_bridges()
1249 * 32-bit prefetchable window (if there is one). in __pci_bus_size_bridges()
1259 * If successful, only non-prefetchable resources in __pci_bus_size_bridges()
1260 * will go in the non-prefetchable window. in __pci_bus_size_bridges()
1272 * non-prefetchable window. This includes: in __pci_bus_size_bridges()
1274 * - all non-prefetchable resources in __pci_bus_size_bridges()
1275 * - 32-bit prefetchable resources if there's a 64-bit in __pci_bus_size_bridges()
1276 * prefetchable window or no prefetchable window at all in __pci_bus_size_bridges()
1277 * - 64-bit prefetchable resources if there's no in __pci_bus_size_bridges()
1278 * prefetchable window at all in __pci_bus_size_bridges()
1282 * 32-bit prefetchable resource in a 64-bit prefetchable in __pci_bus_size_bridges()
1309 if ((r->flags & mask) == (parent_r->flags & mask) && in assign_fixed_resource_on_bus()
1325 struct resource *r = &dev->resource[i]; in pdev_assign_fixed_resources()
1327 if (r->parent || !(r->flags & IORESOURCE_PCI_FIXED) || in pdev_assign_fixed_resources()
1328 !(r->flags & (IORESOURCE_IO | IORESOURCE_MEM))) in pdev_assign_fixed_resources()
1331 b = dev->bus; in pdev_assign_fixed_resources()
1332 while (b && !r->parent) { in pdev_assign_fixed_resources()
1334 b = b->parent; in pdev_assign_fixed_resources()
1348 list_for_each_entry(dev, &bus->devices, bus_list) { in __pci_bus_assign_resources()
1351 b = dev->subordinate; in __pci_bus_assign_resources()
1357 switch (dev->class >> 8) { in __pci_bus_assign_resources()
1369 pci_domain_nr(b), b->number); in __pci_bus_assign_resources()
1386 struct resource *r = &dev->resource[i]; in pci_claim_device_resources()
1388 if (!r->flags || r->parent) in pci_claim_device_resources()
1400 struct resource *r = &dev->resource[i]; in pci_claim_bridge_resources()
1402 if (!r->flags || r->parent) in pci_claim_bridge_resources()
1414 list_for_each_entry(dev, &b->devices, bus_list) { in pci_bus_allocate_dev_resources()
1417 child = dev->subordinate; in pci_bus_allocate_dev_resources()
1428 * Carry out a depth-first search on the PCI bus in pci_bus_allocate_resources()
1433 if (b->self) { in pci_bus_allocate_resources()
1435 pci_claim_bridge_resources(b->self); in pci_bus_allocate_resources()
1438 list_for_each_entry(child, &b->children, node) in pci_bus_allocate_resources()
1458 b = bridge->subordinate; in __pci_bridge_assign_resources()
1464 switch (bridge->class >> 8) { in __pci_bridge_assign_resources()
1475 pci_domain_nr(b), b->number); in __pci_bridge_assign_resources()
1487 struct pci_dev *dev = bus->self; in pci_bridge_release_resources()
1493 b_res = &dev->resource[PCI_BRIDGE_RESOURCES]; in pci_bridge_release_resources()
1498 * 2. if there is non pref mmio assign fail, release bridge in pci_bridge_release_resources()
1522 if (!r->parent) in pci_bridge_release_resources()
1531 type = old_flags = r->flags & PCI_RES_TYPE_MASK; in pci_bridge_release_resources()
1535 r->end = resource_size(r) - 1; in pci_bridge_release_resources()
1536 r->start = 0; in pci_bridge_release_resources()
1537 r->flags = 0; in pci_bridge_release_resources()
1544 r->flags = old_flags; in pci_bridge_release_resources()
1563 list_for_each_entry(dev, &bus->devices, bus_list) { in pci_bus_release_bridge_resources()
1564 struct pci_bus *b = dev->subordinate; in pci_bus_release_bridge_resources()
1570 if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI) in pci_bus_release_bridge_resources()
1581 if ((bus->self->class >> 8) != PCI_CLASS_BRIDGE_PCI) in pci_bus_release_bridge_resources()
1594 if (!res || !res->end || !res->flags) in pci_bus_dump_res()
1597 dev_printk(KERN_DEBUG, &bus->dev, "resource %d %pR\n", i, res); in pci_bus_dump_res()
1609 list_for_each_entry(dev, &bus->devices, bus_list) { in pci_bus_dump_resources()
1610 b = dev->subordinate; in pci_bus_dump_resources()
1623 list_for_each_entry(child_bus, &bus->children, node) { in pci_bus_get_depth()
1635 * -1: undefined, will auto detect later
1642 undefined = -1,
1669 struct resource *r = &dev->resource[i]; in iov_resources_unassigned()
1673 if (!r->flags) in iov_resources_unassigned()
1676 pcibios_resource_to_bus(dev->bus, ®ion, r); in iov_resources_unassigned()
1731 dev_printk(KERN_DEBUG, &bus->dev, in pci_assign_unassigned_root_bus_resources()
1759 dev_info(&bus->dev, "Some PCI device resources are unassigned, try booting with pci=realloc\n"); in pci_assign_unassigned_root_bus_resources()
1761 …dev_info(&bus->dev, "Automatically enabled pci realloc, if you have problem, try booting with pci=… in pci_assign_unassigned_root_bus_resources()
1767 dev_printk(KERN_DEBUG, &bus->dev, in pci_assign_unassigned_root_bus_resources()
1779 pci_bus_release_bridge_resources(fail_res->dev->bus, in pci_assign_unassigned_root_bus_resources()
1780 fail_res->flags & PCI_RES_TYPE_MASK, in pci_assign_unassigned_root_bus_resources()
1785 struct resource *res = fail_res->res; in pci_assign_unassigned_root_bus_resources()
1788 res->start = fail_res->start; in pci_assign_unassigned_root_bus_resources()
1789 res->end = fail_res->end; in pci_assign_unassigned_root_bus_resources()
1790 res->flags = fail_res->flags; in pci_assign_unassigned_root_bus_resources()
1792 if (pci_is_bridge(fail_res->dev)) { in pci_assign_unassigned_root_bus_resources()
1793 idx = res - &fail_res->dev->resource[0]; in pci_assign_unassigned_root_bus_resources()
1796 res->flags = 0; in pci_assign_unassigned_root_bus_resources()
1816 if (ACPI_HANDLE(root_bus->bridge)) in pci_assign_unassigned_resources()
1817 acpi_ioapic_add(ACPI_HANDLE(root_bus->bridge)); in pci_assign_unassigned_resources()
1826 if (res->parent) in extend_bridge_window()
1837 if (available - resource_size(res) <= dev_res->add_size) in extend_bridge_window()
1840 dev_res->add_size = available - resource_size(res); in extend_bridge_window()
1842 &dev_res->add_size); in extend_bridge_window()
1852 struct pci_dev *dev, *bridge = bus->self; in pci_bus_distribute_available_resources()
1854 io_res = &bridge->resource[PCI_BRIDGE_RESOURCES + 0]; in pci_bus_distribute_available_resources()
1855 mmio_res = &bridge->resource[PCI_BRIDGE_RESOURCES + 1]; in pci_bus_distribute_available_resources()
1856 mmio_pref_res = &bridge->resource[PCI_BRIDGE_RESOURCES + 2]; in pci_bus_distribute_available_resources()
1873 * non-hotplug bridges. in pci_bus_distribute_available_resources()
1885 if (dev->is_hotplug_bridge) in pci_bus_distribute_available_resources()
1894 if (dev->is_hotplug_bridge) in pci_bus_distribute_available_resources()
1901 res = &dev->resource[PCI_BRIDGE_RESOURCES + 0]; in pci_bus_distribute_available_resources()
1902 if (!res->parent && available_io > resource_size(res)) in pci_bus_distribute_available_resources()
1903 remaining_io -= resource_size(res); in pci_bus_distribute_available_resources()
1905 res = &dev->resource[PCI_BRIDGE_RESOURCES + 1]; in pci_bus_distribute_available_resources()
1906 if (!res->parent && available_mmio > resource_size(res)) in pci_bus_distribute_available_resources()
1907 remaining_mmio -= resource_size(res); in pci_bus_distribute_available_resources()
1909 res = &dev->resource[PCI_BRIDGE_RESOURCES + 2]; in pci_bus_distribute_available_resources()
1910 if (!res->parent && available_mmio_pref > resource_size(res)) in pci_bus_distribute_available_resources()
1911 remaining_mmio_pref -= resource_size(res); in pci_bus_distribute_available_resources()
1920 dev = list_first_entry(&bus->devices, struct pci_dev, bus_list); in pci_bus_distribute_available_resources()
1921 if (dev->subordinate) { in pci_bus_distribute_available_resources()
1922 pci_bus_distribute_available_resources(dev->subordinate, in pci_bus_distribute_available_resources()
1937 b = dev->subordinate; in pci_bus_distribute_available_resources()
1938 if (!b || !dev->is_hotplug_bridge) in pci_bus_distribute_available_resources()
1943 * hotplug-capable downstream ports taking alignment into in pci_bus_distribute_available_resources()
1951 remaining_io -= io; in pci_bus_distribute_available_resources()
1956 remaining_mmio -= mmio; in pci_bus_distribute_available_resources()
1961 remaining_mmio_pref -= mmio_pref; in pci_bus_distribute_available_resources()
1975 if (!bridge->is_hotplug_bridge) in pci_bridge_distribute_available_resources()
1979 res = &bridge->resource[PCI_BRIDGE_RESOURCES + 0]; in pci_bridge_distribute_available_resources()
1981 res = &bridge->resource[PCI_BRIDGE_RESOURCES + 1]; in pci_bridge_distribute_available_resources()
1983 res = &bridge->resource[PCI_BRIDGE_RESOURCES + 2]; in pci_bridge_distribute_available_resources()
1986 pci_bus_distribute_available_resources(bridge->subordinate, in pci_bridge_distribute_available_resources()
1992 struct pci_bus *parent = bridge->subordinate; in pci_assign_unassigned_bridge_resources()
2031 pci_bus_release_bridge_resources(fail_res->dev->bus, in pci_assign_unassigned_bridge_resources()
2032 fail_res->flags & PCI_RES_TYPE_MASK, in pci_assign_unassigned_bridge_resources()
2037 struct resource *res = fail_res->res; in pci_assign_unassigned_bridge_resources()
2040 res->start = fail_res->start; in pci_assign_unassigned_bridge_resources()
2041 res->end = fail_res->end; in pci_assign_unassigned_bridge_resources()
2042 res->flags = fail_res->flags; in pci_assign_unassigned_bridge_resources()
2044 if (pci_is_bridge(fail_res->dev)) { in pci_assign_unassigned_bridge_resources()
2045 idx = res - &fail_res->dev->resource[0]; in pci_assign_unassigned_bridge_resources()
2048 res->flags = 0; in pci_assign_unassigned_bridge_resources()
2079 struct resource *res = &bridge->resource[i]; in pci_reassign_bridge_resources()
2081 if ((res->flags ^ type) & PCI_RES_TYPE_MASK) in pci_reassign_bridge_resources()
2085 if (res->child) in pci_reassign_bridge_resources()
2095 if (res->parent) in pci_reassign_bridge_resources()
2097 res->start = 0; in pci_reassign_bridge_resources()
2098 res->end = 0; in pci_reassign_bridge_resources()
2104 next = bridge->bus ? bridge->bus->self : NULL; in pci_reassign_bridge_resources()
2108 return -ENOENT; in pci_reassign_bridge_resources()
2110 __pci_bus_size_bridges(bridge->subordinate, &added); in pci_reassign_bridge_resources()
2115 ret = -ENOSPC; in pci_reassign_bridge_resources()
2121 if (bridge == dev_res->dev) in pci_reassign_bridge_resources()
2124 bridge = dev_res->dev; in pci_reassign_bridge_resources()
2125 pci_setup_bridge(bridge->subordinate); in pci_reassign_bridge_resources()
2134 struct resource *res = dev_res->res; in pci_reassign_bridge_resources()
2136 res->start = dev_res->start; in pci_reassign_bridge_resources()
2137 res->end = dev_res->end; in pci_reassign_bridge_resources()
2138 res->flags = dev_res->flags; in pci_reassign_bridge_resources()
2144 struct resource *res = dev_res->res; in pci_reassign_bridge_resources()
2146 bridge = dev_res->dev; in pci_reassign_bridge_resources()
2147 i = res - bridge->resource; in pci_reassign_bridge_resources()
2149 res->start = dev_res->start; in pci_reassign_bridge_resources()
2150 res->end = dev_res->end; in pci_reassign_bridge_resources()
2151 res->flags = dev_res->flags; in pci_reassign_bridge_resources()
2154 pci_setup_bridge(bridge->subordinate); in pci_reassign_bridge_resources()
2170 __pci_bus_size_bridges(dev->subordinate, &add_list); in pci_assign_unassigned_bus_resources()