diff options
| author | Bjorn Helgaas <bhelgaas@google.com> | 2012-02-23 22:19:03 -0500 |
|---|---|---|
| committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-02-23 22:19:03 -0500 |
| commit | 6c5705fec63d83eeb165fe61e34adc92ecc2ce75 (patch) | |
| tree | 80efef86786d06cba09c3ad72dea2e991afd7e8c /arch/powerpc/kernel/pci-common.c | |
| parent | 39c2462e163448c7df466c7262109ec6a24d5f88 (diff) | |
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>
Diffstat (limited to 'arch/powerpc/kernel/pci-common.c')
| -rw-r--r-- | arch/powerpc/kernel/pci-common.c | 79 |
1 files changed, 5 insertions, 74 deletions
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 6d03da475572..910b9dea7037 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c | |||
| @@ -846,60 +846,6 @@ int pci_proc_domain(struct pci_bus *bus) | |||
| 846 | return 1; | 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 | /* This header fixup will do the resource fixup for all devices as they are | 849 | /* This header fixup will do the resource fixup for all devices as they are |
| 904 | * probed, but not for bridge ranges | 850 | * probed, but not for bridge ranges |
| 905 | */ | 851 | */ |
| @@ -939,18 +885,11 @@ static void __devinit pcibios_fixup_resources(struct pci_dev *dev) | |||
| 939 | continue; | 885 | continue; |
| 940 | } | 886 | } |
| 941 | 887 | ||
| 942 | pr_debug("PCI:%s Resource %d %016llx-%016llx [%x] fixup...\n", | 888 | pr_debug("PCI:%s Resource %d %016llx-%016llx [%x]\n", |
| 943 | pci_name(dev), i, | 889 | pci_name(dev), i, |
| 944 | (unsigned long long)res->start,\ | 890 | (unsigned long long)res->start,\ |
| 945 | (unsigned long long)res->end, | 891 | (unsigned long long)res->end, |
| 946 | (unsigned int)res->flags); | 892 | (unsigned int)res->flags); |
| 947 | |||
| 948 | fixup_resource(res, dev); | ||
| 949 | |||
| 950 | pr_debug("PCI:%s %016llx-%016llx\n", | ||
| 951 | pci_name(dev), | ||
| 952 | (unsigned long long)res->start, | ||
| 953 | (unsigned long long)res->end); | ||
| 954 | } | 893 | } |
| 955 | 894 | ||
| 956 | /* Call machine specific resource fixup */ | 895 | /* Call machine specific resource fixup */ |
| @@ -1052,27 +991,18 @@ static void __devinit pcibios_fixup_bridge(struct pci_bus *bus) | |||
| 1052 | continue; | 991 | continue; |
| 1053 | } | 992 | } |
| 1054 | 993 | ||
| 1055 | pr_debug("PCI:%s Bus rsrc %d %016llx-%016llx [%x] fixup...\n", | 994 | pr_debug("PCI:%s Bus rsrc %d %016llx-%016llx [%x]\n", |
| 1056 | pci_name(dev), i, | 995 | pci_name(dev), i, |
| 1057 | (unsigned long long)res->start,\ | 996 | (unsigned long long)res->start,\ |
| 1058 | (unsigned long long)res->end, | 997 | (unsigned long long)res->end, |
| 1059 | (unsigned int)res->flags); | 998 | (unsigned int)res->flags); |
| 1060 | 999 | ||
| 1061 | /* Perform fixup */ | ||
| 1062 | fixup_resource(res, dev); | ||
| 1063 | |||
| 1064 | /* Try to detect uninitialized P2P bridge resources, | 1000 | /* Try to detect uninitialized P2P bridge resources, |
| 1065 | * and clear them out so they get re-assigned later | 1001 | * and clear them out so they get re-assigned later |
| 1066 | */ | 1002 | */ |
| 1067 | if (pcibios_uninitialized_bridge_resource(bus, res)) { | 1003 | if (pcibios_uninitialized_bridge_resource(bus, res)) { |
| 1068 | res->flags = 0; | 1004 | res->flags = 0; |
| 1069 | pr_debug("PCI:%s (unassigned)\n", pci_name(dev)); | 1005 | pr_debug("PCI:%s (unassigned)\n", pci_name(dev)); |
| 1070 | } else { | ||
| 1071 | |||
| 1072 | pr_debug("PCI:%s %016llx-%016llx\n", | ||
| 1073 | pci_name(dev), | ||
| 1074 | (unsigned long long)res->start, | ||
| 1075 | (unsigned long long)res->end); | ||
| 1076 | } | 1006 | } |
| 1077 | } | 1007 | } |
| 1078 | } | 1008 | } |
| @@ -1586,7 +1516,8 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, s | |||
| 1586 | (unsigned long long)res->start, | 1516 | (unsigned long long)res->start, |
| 1587 | (unsigned long long)res->end, | 1517 | (unsigned long long)res->end, |
| 1588 | (unsigned long)res->flags); | 1518 | (unsigned long)res->flags); |
| 1589 | pci_add_resource(resources, res); | 1519 | pci_add_resource_offset(resources, res, |
| 1520 | (resource_size_t) hose->io_base_virt - _IO_BASE); | ||
| 1590 | 1521 | ||
| 1591 | /* Hookup PHB Memory resources */ | 1522 | /* Hookup PHB Memory resources */ |
| 1592 | for (i = 0; i < 3; ++i) { | 1523 | for (i = 0; i < 3; ++i) { |
| @@ -1609,7 +1540,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, s | |||
| 1609 | (unsigned long long)res->start, | 1540 | (unsigned long long)res->start, |
| 1610 | (unsigned long long)res->end, | 1541 | (unsigned long long)res->end, |
| 1611 | (unsigned long)res->flags); | 1542 | (unsigned long)res->flags); |
| 1612 | pci_add_resource(resources, res); | 1543 | pci_add_resource_offset(resources, res, hose->pci_mem_offset); |
| 1613 | } | 1544 | } |
| 1614 | 1545 | ||
| 1615 | pr_debug("PCI: PHB MEM offset = %016llx\n", | 1546 | pr_debug("PCI: PHB MEM offset = %016llx\n", |
