aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/pci_64.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2007-06-04 01:15:36 -0400
committerPaul Mackerras <paulus@samba.org>2007-06-14 08:29:56 -0400
commit3d5134ee8341bffc4f539049abb9e90d469b448d (patch)
tree037958e0daa97b4ef350908a53182167ee2c8a03 /arch/powerpc/kernel/pci_64.c
parentc19c03fc749147f565e807fa65f1729066800571 (diff)
[POWERPC] Rewrite IO allocation & mapping on powerpc64
This rewrites pretty much from scratch the handling of MMIO and PIO space allocations on powerpc64. The main goals are: - Get rid of imalloc and use more common code where possible - Simplify the current mess so that PIO space is allocated and mapped in a single place for PCI bridges - Handle allocation constraints of PIO for all bridges including hot plugged ones within the 2GB space reserved for IO ports, so that devices on hotplugged busses will now work with drivers that assume IO ports fit in an int. - Cleanup and separate tracking of the ISA space in the reserved low 64K of IO space. No ISA -> Nothing mapped there. I booted a cell blade with IDE on PIO and MMIO and a dual G5 so far, that's it :-) With this patch, all allocations are done using the code in mm/vmalloc.c, though we use the low level __get_vm_area with explicit start/stop constraints in order to manage separate areas for vmalloc/vmap, ioremap, and PCI IOs. This greatly simplifies a lot of things, as you can see in the diffstat of that patch :-) A new pair of functions pcibios_map/unmap_io_space() now replace all of the previous code that used to manipulate PCI IOs space. The allocation is done at mapping time, which is now called from scan_phb's, just before the devices are probed (instead of after, which is by itself a bug fix). The only other caller is the PCI hotplug code for hot adding PCI-PCI bridges (slots). imalloc is gone, as is the "sub-allocation" thing, but I do beleive that hotplug should still work in the sense that the space allocation is always done by the PHB, but if you unmap a child bus of this PHB (which seems to be possible), then the code should properly tear down all the HPTE mappings for that area of the PHB allocated IO space. I now always reserve the first 64K of IO space for the bridge with the ISA bus on it. I have moved the code for tracking ISA in a separate file which should also make it smarter if we ever are capable of hot unplugging or re-plugging an ISA bridge. This should have a side effect on platforms like powermac where VGA IOs will no longer work. This is done on purpose though as they would have worked semi-randomly before. The idea at this point is to isolate drivers that might need to access those and fix them by providing a proper function to obtain an offset to the legacy IOs of a given bus. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel/pci_64.c')
-rw-r--r--arch/powerpc/kernel/pci_64.c358
1 files changed, 126 insertions, 232 deletions
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 249cca27a9b8..6ae67ebfab4d 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -11,7 +11,7 @@
11 * 2 of the License, or (at your option) any later version. 11 * 2 of the License, or (at your option) any later version.
12 */ 12 */
13 13
14#undef DEBUG 14#define DEBUG
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/pci.h> 17#include <linux/pci.h>
@@ -22,6 +22,7 @@
22#include <linux/list.h> 22#include <linux/list.h>
23#include <linux/syscalls.h> 23#include <linux/syscalls.h>
24#include <linux/irq.h> 24#include <linux/irq.h>
25#include <linux/vmalloc.h>
25 26
26#include <asm/processor.h> 27#include <asm/processor.h>
27#include <asm/io.h> 28#include <asm/io.h>
@@ -41,35 +42,26 @@
41 42
42unsigned long pci_probe_only = 1; 43unsigned long pci_probe_only = 1;
43int pci_assign_all_buses = 0; 44int pci_assign_all_buses = 0;
44static int pci_initial_scan_done;
45 45
46static void fixup_resource(struct resource *res, struct pci_dev *dev); 46static void fixup_resource(struct resource *res, struct pci_dev *dev);
47static void do_bus_setup(struct pci_bus *bus); 47static void do_bus_setup(struct pci_bus *bus);
48static void phbs_remap_io(void);
49 48
50/* pci_io_base -- the base address from which io bars are offsets. 49/* pci_io_base -- the base address from which io bars are offsets.
51 * This is the lowest I/O base address (so bar values are always positive), 50 * This is the lowest I/O base address (so bar values are always positive),
52 * and it *must* be the start of ISA space if an ISA bus exists because 51 * and it *must* be the start of ISA space if an ISA bus exists because
53 * ISA drivers use hard coded offsets. If no ISA bus exists a dummy 52 * ISA drivers use hard coded offsets. If no ISA bus exists nothing
54 * page is mapped and isa_io_limit prevents access to it. 53 * is mapped on the first 64K of IO space
55 */ 54 */
56unsigned long isa_io_base; /* NULL if no ISA bus */ 55unsigned long pci_io_base = ISA_IO_BASE;
57EXPORT_SYMBOL(isa_io_base);
58unsigned long pci_io_base;
59EXPORT_SYMBOL(pci_io_base); 56EXPORT_SYMBOL(pci_io_base);
60 57
61void iSeries_pcibios_init(void);
62
63LIST_HEAD(hose_list); 58LIST_HEAD(hose_list);
64 59
65static struct dma_mapping_ops *pci_dma_ops; 60static struct dma_mapping_ops *pci_dma_ops;
66 61
62/* XXX kill that some day ... */
67int global_phb_number; /* Global phb counter */ 63int global_phb_number; /* Global phb counter */
68 64
69/* Cached ISA bridge dev. */
70struct pci_dev *ppc64_isabridge_dev = NULL;
71EXPORT_SYMBOL_GPL(ppc64_isabridge_dev);
72
73void set_pci_dma_ops(struct dma_mapping_ops *dma_ops) 65void set_pci_dma_ops(struct dma_mapping_ops *dma_ops)
74{ 66{
75 pci_dma_ops = dma_ops; 67 pci_dma_ops = dma_ops;
@@ -100,7 +92,7 @@ void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region
100 return; 92 return;
101 93
102 if (res->flags & IORESOURCE_IO) 94 if (res->flags & IORESOURCE_IO)
103 offset = (unsigned long)hose->io_base_virt - pci_io_base; 95 offset = (unsigned long)hose->io_base_virt - _IO_BASE;
104 96
105 if (res->flags & IORESOURCE_MEM) 97 if (res->flags & IORESOURCE_MEM)
106 offset = hose->pci_mem_offset; 98 offset = hose->pci_mem_offset;
@@ -119,7 +111,7 @@ void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
119 return; 111 return;
120 112
121 if (res->flags & IORESOURCE_IO) 113 if (res->flags & IORESOURCE_IO)
122 offset = (unsigned long)hose->io_base_virt - pci_io_base; 114 offset = (unsigned long)hose->io_base_virt - _IO_BASE;
123 115
124 if (res->flags & IORESOURCE_MEM) 116 if (res->flags & IORESOURCE_MEM)
125 offset = hose->pci_mem_offset; 117 offset = hose->pci_mem_offset;
@@ -156,7 +148,7 @@ void pcibios_align_resource(void *data, struct resource *res,
156 148
157 if (res->flags & IORESOURCE_IO) { 149 if (res->flags & IORESOURCE_IO) {
158 unsigned long offset = (unsigned long)hose->io_base_virt - 150 unsigned long offset = (unsigned long)hose->io_base_virt -
159 pci_io_base; 151 _IO_BASE;
160 /* Make sure we start at our min on all hoses */ 152 /* Make sure we start at our min on all hoses */
161 if (start - offset < PCIBIOS_MIN_IO) 153 if (start - offset < PCIBIOS_MIN_IO)
162 start = PCIBIOS_MIN_IO + offset; 154 start = PCIBIOS_MIN_IO + offset;
@@ -535,10 +527,16 @@ void __devinit scan_phb(struct pci_controller *hose)
535 bus->secondary = hose->first_busno; 527 bus->secondary = hose->first_busno;
536 hose->bus = bus; 528 hose->bus = bus;
537 529
530 if (!firmware_has_feature(FW_FEATURE_ISERIES))
531 pcibios_map_io_space(bus);
532
538 bus->resource[0] = res = &hose->io_resource; 533 bus->resource[0] = res = &hose->io_resource;
539 if (res->flags && request_resource(&ioport_resource, res)) 534 if (res->flags && request_resource(&ioport_resource, res)) {
540 printk(KERN_ERR "Failed to request PCI IO region " 535 printk(KERN_ERR "Failed to request PCI IO region "
541 "on PCI domain %04x\n", hose->global_number); 536 "on PCI domain %04x\n", hose->global_number);
537 DBG("res->start = 0x%016lx, res->end = 0x%016lx\n",
538 res->start, res->end);
539 }
542 540
543 for (i = 0; i < 3; ++i) { 541 for (i = 0; i < 3; ++i) {
544 res = &hose->mem_resources[i]; 542 res = &hose->mem_resources[i];
@@ -596,17 +594,6 @@ static int __init pcibios_init(void)
596 if (ppc_md.pcibios_fixup) 594 if (ppc_md.pcibios_fixup)
597 ppc_md.pcibios_fixup(); 595 ppc_md.pcibios_fixup();
598 596
599 /* Cache the location of the ISA bridge (if we have one) */
600 ppc64_isabridge_dev = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, NULL);
601 if (ppc64_isabridge_dev != NULL)
602 printk(KERN_DEBUG "ISA bridge at %s\n", pci_name(ppc64_isabridge_dev));
603
604 if (!firmware_has_feature(FW_FEATURE_ISERIES))
605 /* map in PCI I/O space */
606 phbs_remap_io();
607
608 pci_initial_scan_done = 1;
609
610 printk(KERN_DEBUG "PCI: Probing PCI hardware done\n"); 597 printk(KERN_DEBUG "PCI: Probing PCI hardware done\n");
611 598
612 return 0; 599 return 0;
@@ -711,7 +698,7 @@ static struct resource *__pci_mmap_make_offset(struct pci_dev *dev,
711#endif 698#endif
712 res_bit = IORESOURCE_MEM; 699 res_bit = IORESOURCE_MEM;
713 } else { 700 } else {
714 io_offset = (unsigned long)hose->io_base_virt - pci_io_base; 701 io_offset = (unsigned long)hose->io_base_virt - _IO_BASE;
715 *offset += io_offset; 702 *offset += io_offset;
716 res_bit = IORESOURCE_IO; 703 res_bit = IORESOURCE_IO;
717 } 704 }
@@ -881,76 +868,6 @@ void pcibios_add_platform_entries(struct pci_dev *pdev)
881 device_create_file(&pdev->dev, &dev_attr_devspec); 868 device_create_file(&pdev->dev, &dev_attr_devspec);
882} 869}
883 870
884#define ISA_SPACE_MASK 0x1
885#define ISA_SPACE_IO 0x1
886
887static void __devinit pci_process_ISA_OF_ranges(struct device_node *isa_node,
888 unsigned long phb_io_base_phys,
889 void __iomem * phb_io_base_virt)
890{
891 /* Remove these asap */
892
893 struct pci_address {
894 u32 a_hi;
895 u32 a_mid;
896 u32 a_lo;
897 };
898
899 struct isa_address {
900 u32 a_hi;
901 u32 a_lo;
902 };
903
904 struct isa_range {
905 struct isa_address isa_addr;
906 struct pci_address pci_addr;
907 unsigned int size;
908 };
909
910 const struct isa_range *range;
911 unsigned long pci_addr;
912 unsigned int isa_addr;
913 unsigned int size;
914 int rlen = 0;
915
916 range = of_get_property(isa_node, "ranges", &rlen);
917 if (range == NULL || (rlen < sizeof(struct isa_range))) {
918 printk(KERN_ERR "no ISA ranges or unexpected isa range size,"
919 "mapping 64k\n");
920 __ioremap_explicit(phb_io_base_phys,
921 (unsigned long)phb_io_base_virt,
922 0x10000, _PAGE_NO_CACHE | _PAGE_GUARDED);
923 return;
924 }
925
926 /* From "ISA Binding to 1275"
927 * The ranges property is laid out as an array of elements,
928 * each of which comprises:
929 * cells 0 - 1: an ISA address
930 * cells 2 - 4: a PCI address
931 * (size depending on dev->n_addr_cells)
932 * cell 5: the size of the range
933 */
934 if ((range->isa_addr.a_hi && ISA_SPACE_MASK) == ISA_SPACE_IO) {
935 isa_addr = range->isa_addr.a_lo;
936 pci_addr = (unsigned long) range->pci_addr.a_mid << 32 |
937 range->pci_addr.a_lo;
938
939 /* Assume these are both zero */
940 if ((pci_addr != 0) || (isa_addr != 0)) {
941 printk(KERN_ERR "unexpected isa to pci mapping: %s\n",
942 __FUNCTION__);
943 return;
944 }
945
946 size = PAGE_ALIGN(range->size);
947
948 __ioremap_explicit(phb_io_base_phys,
949 (unsigned long) phb_io_base_virt,
950 size, _PAGE_NO_CACHE | _PAGE_GUARDED);
951 }
952}
953
954void __devinit pci_process_bridge_OF_ranges(struct pci_controller *hose, 871void __devinit pci_process_bridge_OF_ranges(struct pci_controller *hose,
955 struct device_node *dev, int prim) 872 struct device_node *dev, int prim)
956{ 873{
@@ -1045,155 +962,122 @@ void __devinit pci_process_bridge_OF_ranges(struct pci_controller *hose,
1045 } 962 }
1046} 963}
1047 964
1048void __devinit pci_setup_phb_io(struct pci_controller *hose, int primary) 965#ifdef CONFIG_HOTPLUG
966
967int pcibios_unmap_io_space(struct pci_bus *bus)
1049{ 968{
1050 unsigned long size = hose->pci_io_size; 969 struct pci_controller *hose;
1051 unsigned long io_virt_offset;
1052 struct resource *res;
1053 struct device_node *isa_dn;
1054 970
1055 if (size == 0) 971 WARN_ON(bus == NULL);
1056 return;
1057 972
1058 hose->io_base_virt = reserve_phb_iospace(size); 973 /* If this is not a PHB, we only flush the hash table over
1059 DBG("phb%d io_base_phys 0x%lx io_base_virt 0x%lx\n", 974 * the area mapped by this bridge. We don't play with the PTE
1060 hose->global_number, hose->io_base_phys, 975 * mappings since we might have to deal with sub-page alignemnts
1061 (unsigned long) hose->io_base_virt); 976 * so flushing the hash table is the only sane way to make sure
1062 977 * that no hash entries are covering that removed bridge area
1063 if (primary) { 978 * while still allowing other busses overlapping those pages
1064 pci_io_base = (unsigned long)hose->io_base_virt; 979 */
1065 isa_dn = of_find_node_by_type(NULL, "isa"); 980 if (bus->self) {
1066 if (isa_dn) { 981 struct resource *res = bus->resource[0];
1067 isa_io_base = pci_io_base;
1068 pci_process_ISA_OF_ranges(isa_dn, hose->io_base_phys,
1069 hose->io_base_virt);
1070 of_node_put(isa_dn);
1071 }
1072 }
1073 982
1074 io_virt_offset = (unsigned long)hose->io_base_virt - pci_io_base; 983 DBG("IO unmapping for PCI-PCI bridge %s\n",
1075 res = &hose->io_resource; 984 pci_name(bus->self));
1076 res->start += io_virt_offset;
1077 res->end += io_virt_offset;
1078 985
1079 /* If this is called after the initial PCI scan, then we need to 986 __flush_hash_table_range(&init_mm, res->start + _IO_BASE,
1080 * proceed to IO mappings now 987 res->end - res->start + 1);
1081 */ 988 return 0;
1082 if (pci_initial_scan_done) 989 }
1083 __ioremap_explicit(hose->io_base_phys,
1084 (unsigned long)hose->io_base_virt,
1085 hose->pci_io_size,
1086 _PAGE_NO_CACHE | _PAGE_GUARDED);
1087}
1088 990
1089void __devinit pci_setup_phb_io_dynamic(struct pci_controller *hose, 991 /* Get the host bridge */
1090 int primary) 992 hose = pci_bus_to_host(bus);
1091{
1092 unsigned long size = hose->pci_io_size;
1093 unsigned long io_virt_offset;
1094 struct resource *res;
1095 993
1096 if (size == 0) 994 /* Check if we have IOs allocated */
1097 return; 995 if (hose->io_base_alloc == 0)
996 return 0;
1098 997
1099 hose->io_base_virt = __ioremap(hose->io_base_phys, size, 998 DBG("IO unmapping for PHB %s\n",
1100 _PAGE_NO_CACHE | _PAGE_GUARDED); 999 ((struct device_node *)hose->arch_data)->full_name);
1101 DBG("phb%d io_base_phys 0x%lx io_base_virt 0x%lx\n", 1000 DBG(" alloc=0x%p\n", hose->io_base_alloc);
1102 hose->global_number, hose->io_base_phys,
1103 (unsigned long) hose->io_base_virt);
1104 1001
1105 if (primary) 1002 /* This is a PHB, we fully unmap the IO area */
1106 pci_io_base = (unsigned long)hose->io_base_virt; 1003 vunmap(hose->io_base_alloc);
1107 1004
1108 io_virt_offset = (unsigned long)hose->io_base_virt - pci_io_base; 1005 return 0;
1109 res = &hose->io_resource;
1110 res->start += io_virt_offset;
1111 res->end += io_virt_offset;
1112} 1006}
1007EXPORT_SYMBOL_GPL(pcibios_unmap_io_space);
1113 1008
1009#endif /* CONFIG_HOTPLUG */
1114 1010
1115static int get_bus_io_range(struct pci_bus *bus, unsigned long *start_phys, 1011int __devinit pcibios_map_io_space(struct pci_bus *bus)
1116 unsigned long *start_virt, unsigned long *size)
1117{ 1012{
1118 struct pci_controller *hose = pci_bus_to_host(bus); 1013 struct vm_struct *area;
1119 struct resource *res; 1014 unsigned long phys_page;
1120 1015 unsigned long size_page;
1121 if (bus->self) 1016 unsigned long io_virt_offset;
1122 res = bus->resource[0]; 1017 struct pci_controller *hose;
1123 else
1124 /* Root Bus */
1125 res = &hose->io_resource;
1126
1127 if (res->end == 0 && res->start == 0)
1128 return 1;
1129 1018
1130 *start_virt = pci_io_base + res->start; 1019 WARN_ON(bus == NULL);
1131 *start_phys = *start_virt + hose->io_base_phys
1132 - (unsigned long) hose->io_base_virt;
1133 1020
1134 if (res->end > res->start) 1021 /* If this not a PHB, nothing to do, page tables still exist and
1135 *size = res->end - res->start + 1; 1022 * thus HPTEs will be faulted in when needed
1136 else { 1023 */
1137 printk("%s(): unexpected region 0x%lx->0x%lx\n", 1024 if (bus->self) {
1138 __FUNCTION__, res->start, res->end); 1025 DBG("IO mapping for PCI-PCI bridge %s\n",
1139 return 1; 1026 pci_name(bus->self));
1027 DBG(" virt=0x%016lx...0x%016lx\n",
1028 bus->resource[0]->start + _IO_BASE,
1029 bus->resource[0]->end + _IO_BASE);
1030 return 0;
1140 } 1031 }
1141 1032
1142 return 0; 1033 /* Get the host bridge */
1143} 1034 hose = pci_bus_to_host(bus);
1144 1035 phys_page = _ALIGN_DOWN(hose->io_base_phys, PAGE_SIZE);
1145int unmap_bus_range(struct pci_bus *bus) 1036 size_page = _ALIGN_UP(hose->pci_io_size, PAGE_SIZE);
1146{
1147 unsigned long start_phys;
1148 unsigned long start_virt;
1149 unsigned long size;
1150
1151 if (!bus) {
1152 printk(KERN_ERR "%s() expected bus\n", __FUNCTION__);
1153 return 1;
1154 }
1155
1156 if (get_bus_io_range(bus, &start_phys, &start_virt, &size))
1157 return 1;
1158 if (__iounmap_explicit((void __iomem *) start_virt, size))
1159 return 1;
1160 1037
1161 return 0; 1038 /* Make sure IO area address is clear */
1162} 1039 hose->io_base_alloc = NULL;
1163EXPORT_SYMBOL(unmap_bus_range);
1164 1040
1165int remap_bus_range(struct pci_bus *bus) 1041 /* If there's no IO to map on that bus, get away too */
1166{ 1042 if (hose->pci_io_size == 0 || hose->io_base_phys == 0)
1167 unsigned long start_phys; 1043 return 0;
1168 unsigned long start_virt;
1169 unsigned long size;
1170 1044
1171 if (!bus) { 1045 /* Let's allocate some IO space for that guy. We don't pass
1172 printk(KERN_ERR "%s() expected bus\n", __FUNCTION__); 1046 * VM_IOREMAP because we don't care about alignment tricks that
1173 return 1; 1047 * the core does in that case. Maybe we should due to stupid card
1174 } 1048 * with incomplete address decoding but I'd rather not deal with
1175 1049 * those outside of the reserved 64K legacy region.
1176 1050 */
1177 if (get_bus_io_range(bus, &start_phys, &start_virt, &size)) 1051 area = __get_vm_area(size_page, 0, PHB_IO_BASE, PHB_IO_END);
1178 return 1; 1052 if (area == NULL)
1179 if (start_phys == 0) 1053 return -ENOMEM;
1180 return 1; 1054 hose->io_base_alloc = area->addr;
1181 printk(KERN_DEBUG "mapping IO %lx -> %lx, size: %lx\n", start_phys, start_virt, size); 1055 hose->io_base_virt = (void __iomem *)(area->addr +
1182 if (__ioremap_explicit(start_phys, start_virt, size, 1056 hose->io_base_phys - phys_page);
1183 _PAGE_NO_CACHE | _PAGE_GUARDED)) 1057
1184 return 1; 1058 DBG("IO mapping for PHB %s\n",
1059 ((struct device_node *)hose->arch_data)->full_name);
1060 DBG(" phys=0x%016lx, virt=0x%p (alloc=0x%p)\n",
1061 hose->io_base_phys, hose->io_base_virt, hose->io_base_alloc);
1062 DBG(" size=0x%016lx (alloc=0x%016lx)\n",
1063 hose->pci_io_size, size_page);
1064
1065 /* Establish the mapping */
1066 if (__ioremap_at(phys_page, area->addr, size_page,
1067 _PAGE_NO_CACHE | _PAGE_GUARDED) == NULL)
1068 return -ENOMEM;
1069
1070 /* Fixup hose IO resource */
1071 io_virt_offset = (unsigned long)hose->io_base_virt - _IO_BASE;
1072 hose->io_resource.start += io_virt_offset;
1073 hose->io_resource.end += io_virt_offset;
1074
1075 DBG(" hose->io_resource=0x%016lx...0x%016lx\n",
1076 hose->io_resource.start, hose->io_resource.end);
1185 1077
1186 return 0; 1078 return 0;
1187} 1079}
1188EXPORT_SYMBOL(remap_bus_range); 1080EXPORT_SYMBOL_GPL(pcibios_map_io_space);
1189
1190static void phbs_remap_io(void)
1191{
1192 struct pci_controller *hose, *tmp;
1193
1194 list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
1195 remap_bus_range(hose->bus);
1196}
1197 1081
1198static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev) 1082static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev)
1199{ 1083{
@@ -1201,8 +1085,7 @@ static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev)
1201 unsigned long offset; 1085 unsigned long offset;
1202 1086
1203 if (res->flags & IORESOURCE_IO) { 1087 if (res->flags & IORESOURCE_IO) {
1204 offset = (unsigned long)hose->io_base_virt - pci_io_base; 1088 offset = (unsigned long)hose->io_base_virt - _IO_BASE;
1205
1206 res->start += offset; 1089 res->start += offset;
1207 res->end += offset; 1090 res->end += offset;
1208 } else if (res->flags & IORESOURCE_MEM) { 1091 } else if (res->flags & IORESOURCE_MEM) {
@@ -1217,9 +1100,20 @@ void __devinit pcibios_fixup_device_resources(struct pci_dev *dev,
1217 /* Update device resources. */ 1100 /* Update device resources. */
1218 int i; 1101 int i;
1219 1102
1220 for (i = 0; i < PCI_NUM_RESOURCES; i++) 1103 DBG("%s: Fixup resources:\n", pci_name(dev));
1221 if (dev->resource[i].flags) 1104 for (i = 0; i < PCI_NUM_RESOURCES; i++) {
1222 fixup_resource(&dev->resource[i], dev); 1105 struct resource *res = &dev->resource[i];
1106 if (!res->flags)
1107 continue;
1108
1109 DBG(" 0x%02x < %08lx:0x%016lx...0x%016lx\n",
1110 i, res->flags, res->start, res->end);
1111
1112 fixup_resource(res, dev);
1113
1114 DBG(" > %08lx:0x%016lx...0x%016lx\n",
1115 res->flags, res->start, res->end);
1116 }
1223} 1117}
1224EXPORT_SYMBOL(pcibios_fixup_device_resources); 1118EXPORT_SYMBOL(pcibios_fixup_device_resources);
1225 1119
@@ -1360,7 +1254,7 @@ void pci_resource_to_user(const struct pci_dev *dev, int bar,
1360 return; 1254 return;
1361 1255
1362 if (rsrc->flags & IORESOURCE_IO) 1256 if (rsrc->flags & IORESOURCE_IO)
1363 offset = (unsigned long)hose->io_base_virt - pci_io_base; 1257 offset = (unsigned long)hose->io_base_virt - _IO_BASE;
1364 1258
1365 /* We pass a fully fixed up address to userland for MMIO instead of 1259 /* We pass a fully fixed up address to userland for MMIO instead of
1366 * a BAR value because X is lame and expects to be able to use that 1260 * a BAR value because X is lame and expects to be able to use that
@@ -1410,7 +1304,7 @@ unsigned long pci_address_to_pio(phys_addr_t address)
1410 if (address >= hose->io_base_phys && 1304 if (address >= hose->io_base_phys &&
1411 address < (hose->io_base_phys + hose->pci_io_size)) { 1305 address < (hose->io_base_phys + hose->pci_io_size)) {
1412 unsigned long base = 1306 unsigned long base =
1413 (unsigned long)hose->io_base_virt - pci_io_base; 1307 (unsigned long)hose->io_base_virt - _IO_BASE;
1414 return base + (address - hose->io_base_phys); 1308 return base + (address - hose->io_base_phys);
1415 } 1309 }
1416 } 1310 }