Skip to content

Commit 5632e2b

Browse files
committed
Revert "PCI: Distribute available resources for root buses, too"
This reverts commit e96e27f. Jonathan reported that this commit broke this topology, where all the space available on bus 02 was assigned to the 02:00.0 bridge window, leaving none for the e1000 device at 02:00.1: pci 0000:00:04.0: bridge window [mem 0x10200000-0x103fffff] to [bus 02-04] pci 0000:02:00.0: bridge window [mem 0x10200000-0x103fffff] to [bus 03-04] pci 0000:02:00.1: BAR 0: failed to assign [mem size 0x00020000] e1000 0000:02:00.1: can't ioremap BAR 0: [??? 0x00000000 flags 0x0] Link: https://lore.kernel.org/r/[email protected] Reported-by: Jonathan Cameron <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 041bc24 commit 5632e2b

File tree

1 file changed

+1
-61
lines changed

1 file changed

+1
-61
lines changed

drivers/pci/setup-bus.c

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,10 +1768,7 @@ static void adjust_bridge_window(struct pci_dev *bridge, struct resource *res,
17681768
}
17691769

17701770
res->end = res->start + new_size - 1;
1771-
1772-
/* If the resource is part of the add_list remove it now */
1773-
if (add_list)
1774-
remove_from_list(add_list, res);
1771+
remove_from_list(add_list, res);
17751772
}
17761773

17771774
static void pci_bus_distribute_available_resources(struct pci_bus *bus,
@@ -1926,8 +1923,6 @@ static void pci_bridge_distribute_available_resources(struct pci_dev *bridge,
19261923
if (!bridge->is_hotplug_bridge)
19271924
return;
19281925

1929-
pci_dbg(bridge, "distributing available resources\n");
1930-
19311926
/* Take the initial extra resources from the hotplug port */
19321927
available_io = bridge->resource[PCI_BRIDGE_IO_WINDOW];
19331928
available_mmio = bridge->resource[PCI_BRIDGE_MEM_WINDOW];
@@ -1939,59 +1934,6 @@ static void pci_bridge_distribute_available_resources(struct pci_dev *bridge,
19391934
available_mmio_pref);
19401935
}
19411936

1942-
static bool pci_bridge_resources_not_assigned(struct pci_dev *dev)
1943-
{
1944-
const struct resource *r;
1945-
1946-
/*
1947-
* Check the child device's resources and if they are not yet
1948-
* assigned it means we are configuring them (not the boot
1949-
* firmware) so we should be able to extend the upstream
1950-
* bridge's (that's the hotplug downstream PCIe port) resources
1951-
* in the same way we do with the normal hotplug case.
1952-
*/
1953-
r = &dev->resource[PCI_BRIDGE_IO_WINDOW];
1954-
if (!r->flags || !(r->flags & IORESOURCE_STARTALIGN))
1955-
return false;
1956-
r = &dev->resource[PCI_BRIDGE_MEM_WINDOW];
1957-
if (!r->flags || !(r->flags & IORESOURCE_STARTALIGN))
1958-
return false;
1959-
r = &dev->resource[PCI_BRIDGE_PREF_MEM_WINDOW];
1960-
if (!r->flags || !(r->flags & IORESOURCE_STARTALIGN))
1961-
return false;
1962-
1963-
return true;
1964-
}
1965-
1966-
static void pci_root_bus_distribute_available_resources(struct pci_bus *bus,
1967-
struct list_head *add_list)
1968-
{
1969-
struct pci_dev *dev, *bridge = bus->self;
1970-
1971-
for_each_pci_bridge(dev, bus) {
1972-
struct pci_bus *b;
1973-
1974-
b = dev->subordinate;
1975-
if (!b)
1976-
continue;
1977-
1978-
/*
1979-
* Need to check "bridge" here too because it is NULL
1980-
* in case of root bus.
1981-
*/
1982-
if (bridge && pci_bridge_resources_not_assigned(dev)) {
1983-
pci_bridge_distribute_available_resources(bridge, add_list);
1984-
/*
1985-
* There is only PCIe upstream port on the bus
1986-
* so we don't need to go futher.
1987-
*/
1988-
return;
1989-
}
1990-
1991-
pci_root_bus_distribute_available_resources(b, add_list);
1992-
}
1993-
}
1994-
19951937
/*
19961938
* First try will not touch PCI bridge res.
19971939
* Second and later try will clear small leaf bridge res.
@@ -2031,8 +1973,6 @@ void pci_assign_unassigned_root_bus_resources(struct pci_bus *bus)
20311973
*/
20321974
__pci_bus_size_bridges(bus, add_list);
20331975

2034-
pci_root_bus_distribute_available_resources(bus, add_list);
2035-
20361976
/* Depth last, allocate resources and update the hardware. */
20371977
__pci_bus_assign_resources(bus, add_list, &fail_head);
20381978
if (add_list)

0 commit comments

Comments
 (0)