Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PCI: Pass bridge window resource to pbus_size_mem()

pbus_size_mem() inputs type and calculates bridge window resource within.
Its caller (__pci_bus_size_bridges()) also has to look up the prefetchable
window to determine if it exists or not to decide whether to call
pbus_size_mem() twice or once.

Change the interface such that the caller is responsible in providing the
bridge window resource. Passing the resource directly avoids another lookup
for the prefetchable window inside pbus_size_mem().

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20251219174036.16738-8-ilpo.jarvinen@linux.intel.com

authored by

Ilpo Järvinen and committed by
Bjorn Helgaas
5819403a d0c72d6e

+17 -18
+17 -18
drivers/pci/setup-bus.c
··· 1262 1262 * pbus_size_mem() - Size the memory window of a given bus 1263 1263 * 1264 1264 * @bus: The bus 1265 - * @type: The type of bridge resource 1265 + * @b_res: The bridge window resource 1266 1266 * @add_size: Additional memory window 1267 1267 * @realloc_head: Track the additional memory window on this list 1268 1268 * 1269 - * Calculate the size of the bus resource for @type and minimal alignment 1269 + * Calculate the size of the bridge window @b_res and minimal alignment 1270 1270 * which guarantees that all child resources fit in this size. 1271 1271 * 1272 1272 * Set the bus resource start/end to indicate the required size if there an ··· 1275 1275 * Add optional resource requests to the @realloc_head list if it is 1276 1276 * supplied. 1277 1277 */ 1278 - static void pbus_size_mem(struct pci_bus *bus, unsigned long type, 1279 - resource_size_t add_size, 1280 - struct list_head *realloc_head) 1278 + static void pbus_size_mem(struct pci_bus *bus, struct resource *b_res, 1279 + resource_size_t add_size, 1280 + struct list_head *realloc_head) 1281 1281 { 1282 1282 struct pci_dev *dev; 1283 1283 resource_size_t min_align, win_align, align, size, size0, size1 = 0; 1284 1284 resource_size_t aligns[28] = {}; /* Alignments from 1MB to 128TB */ 1285 1285 int order, max_order; 1286 - struct resource *b_res = pbus_select_window_for_type(bus, type); 1287 1286 resource_size_t children_add_size = 0; 1288 1287 resource_size_t children_add_align = 0; 1289 1288 resource_size_t add_align = 0; ··· 1493 1494 struct pci_dev *dev; 1494 1495 resource_size_t additional_io_size = 0, additional_mmio_size = 0, 1495 1496 additional_mmio_pref_size = 0; 1496 - struct resource *pref; 1497 + struct resource *b_res; 1497 1498 struct pci_host_bridge *host; 1498 1499 int hdr_type; 1499 1500 ··· 1519 1520 host = to_pci_host_bridge(bus->bridge); 1520 1521 if (!host->size_windows) 1521 1522 return; 1522 - pci_bus_for_each_resource(bus, pref) 1523 - if (pref && (pref->flags & IORESOURCE_PREFETCH)) 1524 - break; 1525 1523 hdr_type = -1; /* Intentionally invalid - not a PCI device. */ 1526 1524 } else { 1527 - pref = &bus->self->resource[PCI_BRIDGE_PREF_MEM_WINDOW]; 1528 1525 hdr_type = bus->self->hdr_type; 1529 1526 } 1530 1527 ··· 1540 1545 default: 1541 1546 pbus_size_io(bus, additional_io_size, realloc_head); 1542 1547 1543 - if (pref && (pref->flags & IORESOURCE_PREFETCH)) { 1544 - pbus_size_mem(bus, 1545 - IORESOURCE_MEM | IORESOURCE_PREFETCH | 1546 - (pref->flags & IORESOURCE_MEM_64), 1547 - additional_mmio_pref_size, realloc_head); 1548 + b_res = pbus_select_window_for_type(bus, IORESOURCE_MEM | 1549 + IORESOURCE_PREFETCH | 1550 + IORESOURCE_MEM_64); 1551 + if (b_res && (b_res->flags & IORESOURCE_PREFETCH)) { 1552 + pbus_size_mem(bus, b_res, additional_mmio_pref_size, 1553 + realloc_head); 1548 1554 } 1549 1555 1550 - pbus_size_mem(bus, IORESOURCE_MEM, additional_mmio_size, 1551 - realloc_head); 1556 + b_res = pbus_select_window_for_type(bus, IORESOURCE_MEM); 1557 + if (b_res) { 1558 + pbus_size_mem(bus, b_res, additional_mmio_size, 1559 + realloc_head); 1560 + } 1552 1561 break; 1553 1562 } 1554 1563 }