]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
powerpc/PCI: compute I/O space bus-to-resource offset consistently
authorBjorn Helgaas <bhelgaas@google.com>
Fri, 16 Mar 2012 23:48:09 +0000 (17:48 -0600)
committerJesse Barnes <jbarnes@virtuousgeek.org>
Tue, 20 Mar 2012 17:41:44 +0000 (10:41 -0700)
Make sure we compute CPU addresses (resource start/end) the same way both
when we set up the I/O aperture (hose->io_resource) and when we use
pcibios_bus_to_resource() to convert BAR values into resources.

This fixes a build failure ("cast from pointer to integer of different
size" in configs where resource_size_t is 64 bits but pointers are 32 bits)
I introduced in 6c5705fec63d.

Acked-By: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
arch/powerpc/include/asm/pci.h
arch/powerpc/kernel/pci-common.c
arch/powerpc/kernel/pci_32.c
arch/powerpc/kernel/pci_64.c

index 201e352d488d7bf5aab4d84d6e16451178a6f9b5..6653f2743c4e60f12fd57e06a75db536d393711a 100644 (file)
@@ -182,6 +182,7 @@ extern void pci_resource_to_user(const struct pci_dev *dev, int bar,
                                 const struct resource *rsrc,
                                 resource_size_t *start, resource_size_t *end);
 
+extern resource_size_t pcibios_io_space_offset(struct pci_controller *hose);
 extern void pcibios_setup_bus_devices(struct pci_bus *bus);
 extern void pcibios_setup_bus_self(struct pci_bus *bus);
 extern void pcibios_setup_phb_io_space(struct pci_controller *hose);
index 910b9dea7037dd03b712868a7ac392e2198caf37..2efd52d714c227a6e90e8aa5c4b3cdf8eced3322 100644 (file)
@@ -1492,6 +1492,11 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
        return pci_enable_resources(dev, mask);
 }
 
+resource_size_t pcibios_io_space_offset(struct pci_controller *hose)
+{
+       return (unsigned long) hose->io_base_virt - _IO_BASE;
+}
+
 static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources)
 {
        struct resource *res;
@@ -1516,8 +1521,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, s
                 (unsigned long long)res->start,
                 (unsigned long long)res->end,
                 (unsigned long)res->flags);
-       pci_add_resource_offset(resources, res,
-                       (resource_size_t) hose->io_base_virt - _IO_BASE);
+       pci_add_resource_offset(resources, res, pcibios_io_space_offset(hose));
 
        /* Hookup PHB Memory resources */
        for (i = 0; i < 3; ++i) {
index fdd1a3d951dcaf50b5e63b72901ef507b9f19a90..4b06ec5a502e2ce47a31d7a6f3d9fa4b1d06bf72 100644 (file)
@@ -219,9 +219,9 @@ void __devinit pcibios_setup_phb_io_space(struct pci_controller *hose)
        struct resource *res = &hose->io_resource;
 
        /* Fixup IO space offset */
-       io_offset = (unsigned long)hose->io_base_virt - isa_io_base;
-       res->start = (res->start + io_offset) & 0xffffffffu;
-       res->end = (res->end + io_offset) & 0xffffffffu;
+       io_offset = pcibios_io_space_offset(hose);
+       res->start += io_offset;
+       res->end += io_offset;
 }
 
 static int __init pcibios_init(void)
index 75417fdc773ca4d67ccd70b7b59b18aaa3431749..94a54f61d341d3363d8bd9b9365964e73aee1346 100644 (file)
@@ -168,7 +168,7 @@ static int __devinit pcibios_map_phb_io_space(struct pci_controller *hose)
                return -ENOMEM;
 
        /* Fixup hose IO resource */
-       io_virt_offset = (unsigned long)hose->io_base_virt - _IO_BASE;
+       io_virt_offset = pcibios_io_space_offset(hose);
        hose->io_resource.start += io_virt_offset;
        hose->io_resource.end += io_virt_offset;