diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2012-03-16 19:48:09 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2012-03-20 13:41:44 -0400 |
commit | 38973ba7903fa0660a31b2bdc50ff711ec8d08c9 (patch) | |
tree | 3035998567d13979639f24d99a5dd185d1679123 | |
parent | d85c6d97d3d2601332f8250f06738cdeb4da71d2 (diff) |
powerpc/PCI: compute I/O space bus-to-resource offset consistently
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>
-rw-r--r-- | arch/powerpc/include/asm/pci.h | 1 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci-common.c | 8 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci_32.c | 6 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci_64.c | 2 |
4 files changed, 11 insertions, 6 deletions
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h index 201e352d488d..6653f2743c4e 100644 --- a/arch/powerpc/include/asm/pci.h +++ b/arch/powerpc/include/asm/pci.h | |||
@@ -182,6 +182,7 @@ extern void pci_resource_to_user(const struct pci_dev *dev, int bar, | |||
182 | const struct resource *rsrc, | 182 | const struct resource *rsrc, |
183 | resource_size_t *start, resource_size_t *end); | 183 | resource_size_t *start, resource_size_t *end); |
184 | 184 | ||
185 | extern resource_size_t pcibios_io_space_offset(struct pci_controller *hose); | ||
185 | extern void pcibios_setup_bus_devices(struct pci_bus *bus); | 186 | extern void pcibios_setup_bus_devices(struct pci_bus *bus); |
186 | extern void pcibios_setup_bus_self(struct pci_bus *bus); | 187 | extern void pcibios_setup_bus_self(struct pci_bus *bus); |
187 | extern void pcibios_setup_phb_io_space(struct pci_controller *hose); | 188 | extern void pcibios_setup_phb_io_space(struct pci_controller *hose); |
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 910b9dea7037..2efd52d714c2 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c | |||
@@ -1492,6 +1492,11 @@ int pcibios_enable_device(struct pci_dev *dev, int mask) | |||
1492 | return pci_enable_resources(dev, mask); | 1492 | return pci_enable_resources(dev, mask); |
1493 | } | 1493 | } |
1494 | 1494 | ||
1495 | resource_size_t pcibios_io_space_offset(struct pci_controller *hose) | ||
1496 | { | ||
1497 | return (unsigned long) hose->io_base_virt - _IO_BASE; | ||
1498 | } | ||
1499 | |||
1495 | static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources) | 1500 | static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources) |
1496 | { | 1501 | { |
1497 | struct resource *res; | 1502 | struct resource *res; |
@@ -1516,8 +1521,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, s | |||
1516 | (unsigned long long)res->start, | 1521 | (unsigned long long)res->start, |
1517 | (unsigned long long)res->end, | 1522 | (unsigned long long)res->end, |
1518 | (unsigned long)res->flags); | 1523 | (unsigned long)res->flags); |
1519 | pci_add_resource_offset(resources, res, | 1524 | pci_add_resource_offset(resources, res, pcibios_io_space_offset(hose)); |
1520 | (resource_size_t) hose->io_base_virt - _IO_BASE); | ||
1521 | 1525 | ||
1522 | /* Hookup PHB Memory resources */ | 1526 | /* Hookup PHB Memory resources */ |
1523 | for (i = 0; i < 3; ++i) { | 1527 | for (i = 0; i < 3; ++i) { |
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c index fdd1a3d951dc..4b06ec5a502e 100644 --- a/arch/powerpc/kernel/pci_32.c +++ b/arch/powerpc/kernel/pci_32.c | |||
@@ -219,9 +219,9 @@ void __devinit pcibios_setup_phb_io_space(struct pci_controller *hose) | |||
219 | struct resource *res = &hose->io_resource; | 219 | struct resource *res = &hose->io_resource; |
220 | 220 | ||
221 | /* Fixup IO space offset */ | 221 | /* Fixup IO space offset */ |
222 | io_offset = (unsigned long)hose->io_base_virt - isa_io_base; | 222 | io_offset = pcibios_io_space_offset(hose); |
223 | res->start = (res->start + io_offset) & 0xffffffffu; | 223 | res->start += io_offset; |
224 | res->end = (res->end + io_offset) & 0xffffffffu; | 224 | res->end += io_offset; |
225 | } | 225 | } |
226 | 226 | ||
227 | static int __init pcibios_init(void) | 227 | static int __init pcibios_init(void) |
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index 75417fdc773c..94a54f61d341 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c | |||
@@ -168,7 +168,7 @@ static int __devinit pcibios_map_phb_io_space(struct pci_controller *hose) | |||
168 | return -ENOMEM; | 168 | return -ENOMEM; |
169 | 169 | ||
170 | /* Fixup hose IO resource */ | 170 | /* Fixup hose IO resource */ |
171 | io_virt_offset = (unsigned long)hose->io_base_virt - _IO_BASE; | 171 | io_virt_offset = pcibios_io_space_offset(hose); |
172 | hose->io_resource.start += io_virt_offset; | 172 | hose->io_resource.start += io_virt_offset; |
173 | hose->io_resource.end += io_virt_offset; | 173 | hose->io_resource.end += io_virt_offset; |
174 | 174 | ||