Skip to content

Commit aaae286

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: Refactor remove_dev_resources() to use pbus_select_window()
Convert remove_dev_resources() to use pbus_select_window(). As 'available' is not the real resources, the index has to be adjusted as only bridge resource counterparts are present in the 'available' array. Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://patch.msgid.link/20250829131113.36754-22-ilpo.jarvinen@linux.intel.com
1 parent 4292a1e commit aaae286

File tree

1 file changed

+9
-25
lines changed

1 file changed

+9
-25
lines changed

drivers/pci/setup-bus.c

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,34 +2062,18 @@ static void remove_dev_resource(struct resource *avail, struct pci_dev *dev,
20622062
static void remove_dev_resources(struct pci_dev *dev,
20632063
struct resource available[PCI_P2P_BRIDGE_RESOURCE_NUM])
20642064
{
2065-
struct resource *mmio_pref = &available[PCI_BUS_BRIDGE_PREF_MEM_WINDOW];
2066-
struct resource *res;
2065+
struct resource *res, *b_win;
2066+
int idx;
20672067

20682068
pci_dev_for_each_resource(dev, res) {
2069-
if (resource_type(res) == IORESOURCE_IO) {
2070-
remove_dev_resource(&available[PCI_BUS_BRIDGE_IO_WINDOW],
2071-
dev, res);
2072-
} else if (resource_type(res) == IORESOURCE_MEM) {
2069+
b_win = pbus_select_window(dev->bus, res);
2070+
if (!b_win)
2071+
continue;
20732072

2074-
/*
2075-
* Make sure prefetchable memory is reduced from
2076-
* the correct resource. Specifically we put 32-bit
2077-
* prefetchable memory in non-prefetchable window
2078-
* if there is a 64-bit prefetchable window.
2079-
*
2080-
* See comments in __pci_bus_size_bridges() for
2081-
* more information.
2082-
*/
2083-
if ((res->flags & IORESOURCE_PREFETCH) &&
2084-
((res->flags & IORESOURCE_MEM_64) ==
2085-
(mmio_pref->flags & IORESOURCE_MEM_64))) {
2086-
remove_dev_resource(&available[PCI_BUS_BRIDGE_PREF_MEM_WINDOW],
2087-
dev, res);
2088-
} else {
2089-
remove_dev_resource(&available[PCI_BUS_BRIDGE_MEM_WINDOW],
2090-
dev, res);
2091-
}
2092-
}
2073+
idx = pci_resource_num(dev->bus->self, b_win);
2074+
idx -= PCI_BRIDGE_RESOURCES;
2075+
2076+
remove_dev_resource(&available[idx], dev, res);
20932077
}
20942078
}
20952079

0 commit comments

Comments
 (0)