Previously we did not turn on automatic PCI resource reallocation for
unassigned IOV resources behind a host bridge with address offset. This
patch fixes that bug.
The intent was that "!r->start" would check for a BAR containing zero. But
that check is incorrect for host bridges that apply an offset, because in
that case the resource address is not the same as the bus address.
This patch fixes that by converting the resource address back to a bus
address before checking for zero.
[bhelgaas: changelog]
Suggested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
for (i = PCI_IOV_RESOURCES; i <= PCI_IOV_RESOURCE_END; i++) {
struct resource *r = &dev->resource[i];
+ struct pci_bus_region region;
/* Not assigned or rejected by kernel? */
- if (r->flags && !r->start) {
+ if (!r->flags)
+ continue;
+
+ pcibios_resource_to_bus(dev, ®ion, r);
+ if (!region.start) {
*unassigned = true;
return 1; /* return early from pci_walk_bus() */
}