Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Bjorn Helgaas and committed by
Jesse Barnes
38973ba7 d85c6d97

+11 -6
+1
arch/powerpc/include/asm/pci.h
··· 182 182 const struct resource *rsrc, 183 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 186 extern void pcibios_setup_bus_devices(struct pci_bus *bus); 186 187 extern void pcibios_setup_bus_self(struct pci_bus *bus); 187 188 extern void pcibios_setup_phb_io_space(struct pci_controller *hose);
+6 -2
arch/powerpc/kernel/pci-common.c
··· 1492 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 1500 static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources) 1496 1501 { 1497 1502 struct resource *res; ··· 1521 1516 (unsigned long long)res->start, 1522 1517 (unsigned long long)res->end, 1523 1518 (unsigned long)res->flags); 1524 - pci_add_resource_offset(resources, res, 1525 - (resource_size_t) hose->io_base_virt - _IO_BASE); 1519 + pci_add_resource_offset(resources, res, pcibios_io_space_offset(hose)); 1526 1520 1527 1521 /* Hookup PHB Memory resources */ 1528 1522 for (i = 0; i < 3; ++i) {
+3 -3
arch/powerpc/kernel/pci_32.c
··· 219 219 struct resource *res = &hose->io_resource; 220 220 221 221 /* Fixup IO space offset */ 222 - io_offset = (unsigned long)hose->io_base_virt - isa_io_base; 223 - res->start = (res->start + io_offset) & 0xffffffffu; 224 - res->end = (res->end + io_offset) & 0xffffffffu; 222 + io_offset = pcibios_io_space_offset(hose); 223 + res->start += io_offset; 224 + res->end += io_offset; 225 225 } 226 226 227 227 static int __init pcibios_init(void)
+1 -1
arch/powerpc/kernel/pci_64.c
··· 168 168 return -ENOMEM; 169 169 170 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 172 hose->io_resource.start += io_virt_offset; 173 173 hose->io_resource.end += io_virt_offset; 174 174