arm/PCI: get rid of device resource fixups
Bjorn Helgaas [Fri, 24 Feb 2012 03:19:01 +0000 (20:19 -0700)]
Tell the PCI core about host bridge address translation so it can take
care of bus-to-resource conversion for us.

CC: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

19 files changed:
arch/arm/common/it8152.c
arch/arm/include/asm/pci.h
arch/arm/kernel/bios32.c
arch/arm/mach-cns3xxx/pcie.c
arch/arm/mach-dove/pcie.c
arch/arm/mach-footbridge/dc21285.c
arch/arm/mach-integrator/pci_v3.c
arch/arm/mach-iop13xx/pci.c
arch/arm/mach-ixp2000/pci.c
arch/arm/mach-ixp23xx/pci.c
arch/arm/mach-ixp4xx/common-pci.c
arch/arm/mach-kirkwood/pcie.c
arch/arm/mach-ks8695/pci.c
arch/arm/mach-mv78xx0/pcie.c
arch/arm/mach-orion5x/pci.c
arch/arm/mach-sa1100/pci-nanoengine.c
arch/arm/mach-tegra/pcie.c
arch/arm/mach-versatile/pci.c
arch/arm/plat-iop/pci.c

index d1bcd7b..9384c2d 100644 (file)
@@ -299,8 +299,8 @@ int __init it8152_pci_setup(int nr, struct pci_sys_data *sys)
                goto err1;
        }
 
-       pci_add_resource(&sys->resources, &it8152_io);
-       pci_add_resource(&sys->resources, &it8152_mem);
+       pci_add_resource_offset(&sys->resources, &it8152_io, sys->io_offset);
+       pci_add_resource_offset(&sys->resources, &it8152_mem, sys->mem_offset);
 
        if (platform_notify || platform_notify_remove) {
                printk(KERN_ERR "PCI: Can't use platform_notify\n");
index da337ba..4748a75 100644 (file)
@@ -57,13 +57,7 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
 extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
                                enum pci_mmap_state mmap_state, int write_combine);
 
-extern void
-pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
-                        struct resource *res);
-
-extern void
-pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
-                       struct pci_bus_region *region);
+#define ARCH_HAS_GENERIC_PCI_OFFSETS
 
 /*
  * Dummy implementation; always return 0.
index 8d7c22d..be5d3b2 100644 (file)
@@ -294,28 +294,6 @@ static inline int pdev_bad_for_parity(struct pci_dev *dev)
 }
 
 /*
- * Adjust the device resources from bus-centric to Linux-centric.
- */
-static void __devinit
-pdev_fixup_device_resources(struct pci_sys_data *root, struct pci_dev *dev)
-{
-       resource_size_t offset;
-       int i;
-
-       for (i = 0; i < PCI_NUM_RESOURCES; i++) {
-               if (dev->resource[i].start == 0)
-                       continue;
-               if (dev->resource[i].flags & IORESOURCE_MEM)
-                       offset = root->mem_offset;
-               else
-                       offset = root->io_offset;
-
-               dev->resource[i].start += offset;
-               dev->resource[i].end   += offset;
-       }
-}
-
-/*
  * pcibios_fixup_bus - Called after each bus is probed,
  * but before its children are examined.
  */
@@ -332,8 +310,6 @@ void pcibios_fixup_bus(struct pci_bus *bus)
        list_for_each_entry(dev, &bus->devices, bus_list) {
                u16 status;
 
-               pdev_fixup_device_resources(root, dev);
-
                pci_read_config_word(dev, PCI_STATUS, &status);
 
                /*
@@ -399,43 +375,6 @@ EXPORT_SYMBOL(pcibios_fixup_bus);
 #endif
 
 /*
- * Convert from Linux-centric to bus-centric addresses for bridge devices.
- */
-void
-pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
-                        struct resource *res)
-{
-       struct pci_sys_data *root = dev->sysdata;
-       unsigned long offset = 0;
-
-       if (res->flags & IORESOURCE_IO)
-               offset = root->io_offset;
-       if (res->flags & IORESOURCE_MEM)
-               offset = root->mem_offset;
-
-       region->start = res->start - offset;
-       region->end   = res->end - offset;
-}
-EXPORT_SYMBOL(pcibios_resource_to_bus);
-
-void __devinit
-pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
-                       struct pci_bus_region *region)
-{
-       struct pci_sys_data *root = dev->sysdata;
-       unsigned long offset = 0;
-
-       if (res->flags & IORESOURCE_IO)
-               offset = root->io_offset;
-       if (res->flags & IORESOURCE_MEM)
-               offset = root->mem_offset;
-
-       res->start = region->start + offset;
-       res->end   = region->end + offset;
-}
-EXPORT_SYMBOL(pcibios_bus_to_resource);
-
-/*
  * Swizzle the device pin each time we cross a bridge.
  * This might update pin and returns the slot number.
  */
@@ -496,10 +435,10 @@ static void __init pcibios_init_hw(struct hw_pci *hw)
 
                if (ret > 0) {
                        if (list_empty(&sys->resources)) {
-                               pci_add_resource(&sys->resources,
-                                                &ioport_resource);
-                               pci_add_resource(&sys->resources,
-                                                &iomem_resource);
+                               pci_add_resource_offset(&sys->resources,
+                                        &ioport_resource, sys->io_offset);
+                               pci_add_resource_offset(&sys->resources,
+                                        &iomem_resource, sys->mem_offset);
                        }
 
                        sys->bus = hw->scan(nr, sys);
index e159d69..79d001f 100644 (file)
@@ -155,8 +155,8 @@ static int cns3xxx_pci_setup(int nr, struct pci_sys_data *sys)
        BUG_ON(request_resource(&iomem_resource, res_io) ||
               request_resource(&iomem_resource, res_mem));
 
-       pci_add_resource(&sys->resources, res_io);
-       pci_add_resource(&sys->resources, res_mem);
+       pci_add_resource_offset(&sys->resources, res_io, sys->io_offset);
+       pci_add_resource_offset(&sys->resources, res_mem, sys->mem_offset);
 
        return 1;
 }
index 52e96d3..48a0320 100644 (file)
@@ -69,7 +69,7 @@ static int __init dove_pcie_setup(int nr, struct pci_sys_data *sys)
        pp->res[0].flags = IORESOURCE_IO;
        if (request_resource(&ioport_resource, &pp->res[0]))
                panic("Request PCIe IO resource failed\n");
-       pci_add_resource(&sys->resources, &pp->res[0]);
+       pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset);
 
        /*
         * IORESOURCE_MEM
@@ -88,7 +88,7 @@ static int __init dove_pcie_setup(int nr, struct pci_sys_data *sys)
        pp->res[1].flags = IORESOURCE_MEM;
        if (request_resource(&iomem_resource, &pp->res[1]))
                panic("Request PCIe Memory resource failed\n");
-       pci_add_resource(&sys->resources, &pp->res[1]);
+       pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset);
 
        return 1;
 }
index f685650..3194d3f 100644 (file)
@@ -275,11 +275,13 @@ int __init dc21285_setup(int nr, struct pci_sys_data *sys)
        allocate_resource(&iomem_resource, &res[0], 0x40000000,
                          0x80000000, 0xffffffff, 0x40000000, NULL, NULL);
 
-       pci_add_resource(&sys->resources, &ioport_resource);
-       pci_add_resource(&sys->resources, &res[0]);
-       pci_add_resource(&sys->resources, &res[1]);
        sys->mem_offset  = DC21285_PCI_MEM;
 
+       pci_add_resource_offset(&sys->resources,
+                               &ioport_resource, sys->io_offset);
+       pci_add_resource_offset(&sys->resources, &res[0], sys->mem_offset);
+       pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
+
        return 1;
 }
 
index 3c82566..015be77 100644 (file)
@@ -378,9 +378,10 @@ static int __init pci_v3_setup_resources(struct pci_sys_data *sys)
         * the mem resource for this bus
         * the prefetch mem resource for this bus
         */
-       pci_add_resource(&sys->resources, &ioport_resource);
-       pci_add_resource(&sys->resources, &non_mem);
-       pci_add_resource(&sys->resources, &pre_mem);
+       pci_add_resource_offset(&sys->resources,
+                               &ioport_resource, sys->io_offset);
+       pci_add_resource_offset(&sys->resources, &non_mem, sys->mem_offset);
+       pci_add_resource_offset(&sys->resources, &pre_mem, sys->mem_offset);
 
        return 1;
 }
index b8f5a87..861cb12 100644 (file)
@@ -1084,8 +1084,8 @@ int iop13xx_pci_setup(int nr, struct pci_sys_data *sys)
        request_resource(&ioport_resource, &res[0]);
        request_resource(&iomem_resource, &res[1]);
 
-       pci_add_resource(&sys->resources, &res[0]);
-       pci_add_resource(&sys->resources, &res[1]);
+       pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset);
+       pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
 
        return 1;
 }
index 626fda4..49c36f3 100644 (file)
@@ -243,8 +243,10 @@ int ixp2000_pci_setup(int nr, struct pci_sys_data *sys)
        if (nr >= 1)
                return 0;
 
-       pci_add_resource(&sys->resources, &ixp2000_pci_io_space);
-       pci_add_resource(&sys->resources, &ixp2000_pci_mem_space);
+       pci_add_resource_offset(&sys->resources,
+                               &ixp2000_pci_io_space, sys->io_offset);
+       pci_add_resource_offset(&sys->resources,
+                               &ixp2000_pci_mem_space, sys->mem_offset);
 
        return 1;
 }
index 25b5c46..3cbbd32 100644 (file)
@@ -281,8 +281,10 @@ int ixp23xx_pci_setup(int nr, struct pci_sys_data *sys)
        if (nr >= 1)
                return 0;
 
-       pci_add_resource(&sys->resources, &ixp23xx_pci_io_space);
-       pci_add_resource(&sys->resources, &ixp23xx_pci_mem_space);
+       pci_add_resource_offset(&sys->resources,
+                               &ixp23xx_pci_io_space, sys->io_offset);
+       pci_add_resource_offset(&sys->resources,
+                               &ixp23xx_pci_mem_space, sys->mem_offset);
 
        return 1;
 }
index 5eff15f..8508882 100644 (file)
@@ -472,8 +472,8 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys)
        request_resource(&ioport_resource, &res[0]);
        request_resource(&iomem_resource, &res[1]);
 
-       pci_add_resource(&sys->resources, &res[0]);
-       pci_add_resource(&sys->resources, &res[1]);
+       pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset);
+       pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
 
        platform_notify = ixp4xx_pci_platform_notify;
        platform_notify_remove = ixp4xx_pci_platform_notify_remove;
index a066a6d..f56a011 100644 (file)
@@ -198,9 +198,9 @@ static int __init kirkwood_pcie_setup(int nr, struct pci_sys_data *sys)
        if (request_resource(&iomem_resource, &pp->res[1]))
                panic("Request PCIe%d Memory resource failed\n", index);
 
-       pci_add_resource(&sys->resources, &pp->res[0]);
-       pci_add_resource(&sys->resources, &pp->res[1]);
        sys->io_offset = 0;
+       pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset);
+       pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset);
 
        /*
         * Generic PCIe unit setup.
index b26f992..acc7014 100644 (file)
@@ -169,8 +169,8 @@ static int __init ks8695_pci_setup(int nr, struct pci_sys_data *sys)
        request_resource(&iomem_resource, &pci_mem);
        request_resource(&ioport_resource, &pci_io);
 
-       pci_add_resource(&sys->resources, &pci_io);
-       pci_add_resource(&sys->resources, &pci_mem);
+       pci_add_resource_offset(&sys->resources, &pci_io, sys->io_offset);
+       pci_add_resource_offset(&sys->resources, &pci_mem, sys->mem_offset);
 
        /* Assign and enable processor bridge */
        ks8695_local_writeconfig(PCI_BASE_ADDRESS_0, KS8695_PCIMEM_PA);
index 8459f6d..df3e380 100644 (file)
@@ -155,8 +155,8 @@ static int __init mv78xx0_pcie_setup(int nr, struct pci_sys_data *sys)
        orion_pcie_set_local_bus_nr(pp->base, sys->busnr);
        orion_pcie_setup(pp->base);
 
-       pci_add_resource(&sys->resources, &pp->res[0]);
-       pci_add_resource(&sys->resources, &pp->res[1]);
+       pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset);
+       pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset);
 
        return 1;
 }
index 09a045f..d6a9194 100644 (file)
@@ -171,13 +171,14 @@ static int __init pcie_setup(struct pci_sys_data *sys)
        /*
         * IORESOURCE_IO
         */
+       sys->io_offset = 0;
        res[0].name = "PCIe I/O Space";
        res[0].flags = IORESOURCE_IO;
        res[0].start = ORION5X_PCIE_IO_BUS_BASE;
        res[0].end = res[0].start + ORION5X_PCIE_IO_SIZE - 1;
        if (request_resource(&ioport_resource, &res[0]))
                panic("Request PCIe IO resource failed\n");
-       pci_add_resource(&sys->resources, &res[0]);
+       pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset);
 
        /*
         * IORESOURCE_MEM
@@ -188,9 +189,7 @@ static int __init pcie_setup(struct pci_sys_data *sys)
        res[1].end = res[1].start + ORION5X_PCIE_MEM_SIZE - 1;
        if (request_resource(&iomem_resource, &res[1]))
                panic("Request PCIe Memory resource failed\n");
-       pci_add_resource(&sys->resources, &res[1]);
-
-       sys->io_offset = 0;
+       pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
 
        return 1;
 }
@@ -499,13 +498,14 @@ static int __init pci_setup(struct pci_sys_data *sys)
        /*
         * IORESOURCE_IO
         */
+       sys->io_offset = 0;
        res[0].name = "PCI I/O Space";
        res[0].flags = IORESOURCE_IO;
        res[0].start = ORION5X_PCI_IO_BUS_BASE;
        res[0].end = res[0].start + ORION5X_PCI_IO_SIZE - 1;
        if (request_resource(&ioport_resource, &res[0]))
                panic("Request PCI IO resource failed\n");
-       pci_add_resource(&sys->resources, &res[0]);
+       pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset);
 
        /*
         * IORESOURCE_MEM
@@ -516,9 +516,7 @@ static int __init pci_setup(struct pci_sys_data *sys)
        res[1].end = res[1].start + ORION5X_PCI_MEM_SIZE - 1;
        if (request_resource(&iomem_resource, &res[1]))
                panic("Request PCI Memory resource failed\n");
-       pci_add_resource(&sys->resources, &res[1]);
-
-       sys->io_offset = 0;
+       pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
 
        return 1;
 }
index 0d01ca7..b466bca 100644 (file)
@@ -244,9 +244,11 @@ static int __init pci_nanoengine_setup_resources(struct pci_sys_data *sys)
                printk(KERN_ERR "PCI: unable to allocate prefetchable\n");
                return -EBUSY;
        }
-       pci_add_resource(&sys->resources, &pci_io_ports);
-       pci_add_resource(&sys->resources, &pci_non_prefetchable_memory);
-       pci_add_resource(&sys->resources, &pci_prefetchable_memory);
+       pci_add_resource_offset(&sys->resources, &pci_io_ports, sys->io_offset);
+       pci_add_resource_offset(&sys->resources,
+                               &pci_non_prefetchable_memory, sys->mem_offset);
+       pci_add_resource_offset(&sys->resources,
+                               &pci_prefetchable_memory, sys->mem_offset);
 
        return 1;
 }
index af8b634..14b29ab 100644 (file)
@@ -408,7 +408,7 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
        pp->res[0].flags = IORESOURCE_IO;
        if (request_resource(&ioport_resource, &pp->res[0]))
                panic("Request PCIe IO resource failed\n");
-       pci_add_resource(&sys->resources, &pp->res[0]);
+       pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset);
 
        /*
         * IORESOURCE_MEM
@@ -427,7 +427,7 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
        pp->res[1].flags = IORESOURCE_MEM;
        if (request_resource(&iomem_resource, &pp->res[1]))
                panic("Request PCIe Memory resource failed\n");
-       pci_add_resource(&sys->resources, &pp->res[1]);
+       pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset);
 
        /*
         * IORESOURCE_MEM | IORESOURCE_PREFETCH
@@ -446,7 +446,7 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
        pp->res[2].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
        if (request_resource(&iomem_resource, &pp->res[2]))
                panic("Request PCIe Prefetch Memory resource failed\n");
-       pci_add_resource(&sys->resources, &pp->res[2]);
+       pci_add_resource_offset(&sys->resources, &pp->res[2], sys->mem_offset);
 
        return 1;
 }
index 90069bc..51733b0 100644 (file)
@@ -219,9 +219,9 @@ static int __init pci_versatile_setup_resources(struct list_head *resources)
         * the mem resource for this bus
         * the prefetch mem resource for this bus
         */
-       pci_add_resource(resources, &io_mem);
-       pci_add_resource(resources, &non_mem);
-       pci_add_resource(resources, &pre_mem);
+       pci_add_resource_offset(resources, &io_mem, sys->io_offset);
+       pci_add_resource_offset(resources, &non_mem, sys->mem_offset);
+       pci_add_resource_offset(resources, &pre_mem, sys->mem_offset);
 
        goto out;
 
index f4d40a2..7276835 100644 (file)
@@ -215,8 +215,8 @@ int iop3xx_pci_setup(int nr, struct pci_sys_data *sys)
        sys->mem_offset = IOP3XX_PCI_LOWER_MEM_PA - *IOP3XX_OMWTVR0;
        sys->io_offset  = IOP3XX_PCI_LOWER_IO_PA - *IOP3XX_OIOWTVR;
 
-       pci_add_resource(&sys->resources, &res[0]);
-       pci_add_resource(&sys->resources, &res[1]);
+       pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset);
+       pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
 
        return 1;
 }