@@ -881,6 +881,8 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
child->msi = parent->msi;
child->sysdata = parent->sysdata;
child->bus_flags = parent->bus_flags;
+ child->iomem_res = parent->iomem_res;
+ child->ioport_res = parent->ioport_res;
/* initialize some portions of the bus device, but don't register it
* now as the parent is not properly set up yet.
@@ -1617,7 +1617,7 @@ static void quirk_alder_ioapic(struct pci_dev *pdev)
* not touch this (and it's already covered by the fixmap), so
* forcibly insert it into the resource tree */
if (pci_resource_start(pdev, 0) && pci_resource_len(pdev, 0))
- insert_resource(&iomem_resource, &pdev->resource[0]);
+ insert_resource(iomem_res(pdev->bus), &pdev->resource[0]);
/* The next five BARs all seem to be rubbish, so just clean
* them out */
@@ -805,7 +805,7 @@ static struct resource *find_free_bus_resource(struct pci_bus *bus,
struct resource *r;
pci_bus_for_each_resource(bus, r, i) {
- if (r == &ioport_resource || r == &iomem_resource)
+ if (r == ioport_res(bus) || r == iomem_res(bus))
continue;
if (r && (r->flags & type_mask) == type && !r->parent)
return r;
@@ -215,9 +215,9 @@ static int pci_revert_fw_address(struct resource *res, struct pci_dev *dev,
root = pci_find_parent_resource(dev, res);
if (!root) {
if (res->flags & IORESOURCE_IO)
- root = &ioport_resource;
+ root = ioport_res(dev->bus);
else
- root = &iomem_resource;
+ root = iomem_res(dev->bus);
}
dev_info(&dev->dev, "BAR %d: trying firmware assignment %pR\n",
@@ -524,6 +524,9 @@ struct pci_bus {
void *sysdata; /* hook for sys-specific extension */
struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */
+ struct resource *iomem_res; /* pointer to root iomem_resource */
+ struct resource *ioport_res; /* pointer to root ioport_resource */
+
unsigned char number; /* bus number */
unsigned char primary; /* number of primary bridge */
unsigned char max_bus_speed; /* enum pci_bus_speed */
@@ -545,6 +548,16 @@ struct pci_bus {
#define to_pci_bus(n) container_of(n, struct pci_bus, dev)
+static inline struct resource *iomem_res(struct pci_bus *bus)
+{
+ return bus->iomem_res ? : &iomem_resource;
+}
+
+static inline struct resource *ioport_res(struct pci_bus *bus)
+{
+ return bus->ioport_res ? : &ioport_resource;
+}
+
/*
* Returns true if the PCI bus is root (behind host-PCI bridge),
* false otherwise
Make every bus to take the pointer to correct iomem_res instead of using iomem_resource directly. So PCI_TEST could use different iomem_res later. Signed-off-by: Yinghai Lu <yinghai@kernel.org> --- drivers/pci/probe.c | 2 ++ drivers/pci/quirks.c | 2 +- drivers/pci/setup-bus.c | 2 +- drivers/pci/setup-res.c | 4 ++-- include/linux/pci.h | 13 +++++++++++++ 5 files changed, 19 insertions(+), 4 deletions(-)