From: Yinghai Lu Date: Mon, 22 Jul 2013 21:37:14 +0000 (-0700) Subject: PCI: Turn on reallocation for unassigned resources with host bridge offset X-Git-Tag: next-20130912~201^2~3^2~5 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=fa216bf4dbe35e15044b90e7b51509768bab3d9a;p=karo-tx-linux.git PCI: Turn on reallocation for unassigned resources with host bridge offset 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 Signed-off-by: Yinghai Lu Signed-off-by: Bjorn Helgaas --- diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 20c09bd652db..ed1bd0cdf521 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1367,9 +1367,14 @@ static int __init iov_resources_unassigned(struct pci_dev *dev, void *data) 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() */ }