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

powerpc/PCI: get rid of device resource fixups

Tell the PCI core about host bridge address translation so it can take
care of bus-to-resource conversion for us.

CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

+6 -81
+1 -7
arch/powerpc/include/asm/pci.h
··· 154 154 155 155 #endif /* CONFIG_PPC64 */ 156 156 157 - extern void pcibios_resource_to_bus(struct pci_dev *dev, 158 - struct pci_bus_region *region, 159 - struct resource *res); 160 - 161 - extern void pcibios_bus_to_resource(struct pci_dev *dev, 162 - struct resource *res, 163 - struct pci_bus_region *region); 157 + #define ARCH_HAS_GENERIC_PCI_OFFSETS 164 158 165 159 extern void pcibios_claim_one_bus(struct pci_bus *b); 166 160
+5 -74
arch/powerpc/kernel/pci-common.c
··· 846 846 return 1; 847 847 } 848 848 849 - void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 850 - struct resource *res) 851 - { 852 - resource_size_t offset = 0, mask = (resource_size_t)-1; 853 - struct pci_controller *hose = pci_bus_to_host(dev->bus); 854 - 855 - if (!hose) 856 - return; 857 - if (res->flags & IORESOURCE_IO) { 858 - offset = (unsigned long)hose->io_base_virt - _IO_BASE; 859 - mask = 0xffffffffu; 860 - } else if (res->flags & IORESOURCE_MEM) 861 - offset = hose->pci_mem_offset; 862 - 863 - region->start = (res->start - offset) & mask; 864 - region->end = (res->end - offset) & mask; 865 - } 866 - EXPORT_SYMBOL(pcibios_resource_to_bus); 867 - 868 - void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 869 - struct pci_bus_region *region) 870 - { 871 - resource_size_t offset = 0, mask = (resource_size_t)-1; 872 - struct pci_controller *hose = pci_bus_to_host(dev->bus); 873 - 874 - if (!hose) 875 - return; 876 - if (res->flags & IORESOURCE_IO) { 877 - offset = (unsigned long)hose->io_base_virt - _IO_BASE; 878 - mask = 0xffffffffu; 879 - } else if (res->flags & IORESOURCE_MEM) 880 - offset = hose->pci_mem_offset; 881 - res->start = (region->start + offset) & mask; 882 - res->end = (region->end + offset) & mask; 883 - } 884 - EXPORT_SYMBOL(pcibios_bus_to_resource); 885 - 886 - /* Fixup a bus resource into a linux resource */ 887 - static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev) 888 - { 889 - struct pci_controller *hose = pci_bus_to_host(dev->bus); 890 - resource_size_t offset = 0, mask = (resource_size_t)-1; 891 - 892 - if (res->flags & IORESOURCE_IO) { 893 - offset = (unsigned long)hose->io_base_virt - _IO_BASE; 894 - mask = 0xffffffffu; 895 - } else if (res->flags & IORESOURCE_MEM) 896 - offset = hose->pci_mem_offset; 897 - 898 - res->start = (res->start + offset) & mask; 899 - res->end = (res->end + offset) & mask; 900 - } 901 - 902 - 903 849 /* This header fixup will do the resource fixup for all devices as they are 904 850 * probed, but not for bridge ranges 905 851 */ ··· 885 939 continue; 886 940 } 887 941 888 - pr_debug("PCI:%s Resource %d %016llx-%016llx [%x] fixup...\n", 942 + pr_debug("PCI:%s Resource %d %016llx-%016llx [%x]\n", 889 943 pci_name(dev), i, 890 944 (unsigned long long)res->start,\ 891 945 (unsigned long long)res->end, 892 946 (unsigned int)res->flags); 893 - 894 - fixup_resource(res, dev); 895 - 896 - pr_debug("PCI:%s %016llx-%016llx\n", 897 - pci_name(dev), 898 - (unsigned long long)res->start, 899 - (unsigned long long)res->end); 900 947 } 901 948 902 949 /* Call machine specific resource fixup */ ··· 991 1052 continue; 992 1053 } 993 1054 994 - pr_debug("PCI:%s Bus rsrc %d %016llx-%016llx [%x] fixup...\n", 1055 + pr_debug("PCI:%s Bus rsrc %d %016llx-%016llx [%x]\n", 995 1056 pci_name(dev), i, 996 1057 (unsigned long long)res->start,\ 997 1058 (unsigned long long)res->end, 998 1059 (unsigned int)res->flags); 999 - 1000 - /* Perform fixup */ 1001 - fixup_resource(res, dev); 1002 1060 1003 1061 /* Try to detect uninitialized P2P bridge resources, 1004 1062 * and clear them out so they get re-assigned later ··· 1003 1067 if (pcibios_uninitialized_bridge_resource(bus, res)) { 1004 1068 res->flags = 0; 1005 1069 pr_debug("PCI:%s (unassigned)\n", pci_name(dev)); 1006 - } else { 1007 - 1008 - pr_debug("PCI:%s %016llx-%016llx\n", 1009 - pci_name(dev), 1010 - (unsigned long long)res->start, 1011 - (unsigned long long)res->end); 1012 1070 } 1013 1071 } 1014 1072 } ··· 1516 1586 (unsigned long long)res->start, 1517 1587 (unsigned long long)res->end, 1518 1588 (unsigned long)res->flags); 1519 - pci_add_resource(resources, res); 1589 + pci_add_resource_offset(resources, res, 1590 + (resource_size_t) hose->io_base_virt - _IO_BASE); 1520 1591 1521 1592 /* Hookup PHB Memory resources */ 1522 1593 for (i = 0; i < 3; ++i) { ··· 1540 1609 (unsigned long long)res->start, 1541 1610 (unsigned long long)res->end, 1542 1611 (unsigned long)res->flags); 1543 - pci_add_resource(resources, res); 1612 + pci_add_resource_offset(resources, res, hose->pci_mem_offset); 1544 1613 } 1545 1614 1546 1615 pr_debug("PCI: PHB MEM offset = %016llx\n",