aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/alpha/kernel/pci-sysfs.c4
-rw-r--r--arch/powerpc/kernel/pci-common.c4
-rw-r--r--arch/powerpc/kernel/pci_of_scan.c4
-rw-r--r--arch/sparc/kernel/pci.c6
-rw-r--r--arch/x86/include/asm/pci.h1
-rw-r--r--drivers/char/agp/agp.h1
-rw-r--r--drivers/char/agp/ali-agp.c4
-rw-r--r--drivers/char/agp/amd-k7-agp.c12
-rw-r--r--drivers/char/agp/amd64-agp.c5
-rw-r--r--drivers/char/agp/ati-agp.c21
-rw-r--r--drivers/char/agp/efficeon-agp.c5
-rw-r--r--drivers/char/agp/generic.c4
-rw-r--r--drivers/char/agp/intel-agp.c48
-rw-r--r--drivers/char/agp/intel-agp.h10
-rw-r--r--drivers/char/agp/intel-gtt.c47
-rw-r--r--drivers/char/agp/nvidia-agp.c9
-rw-r--r--drivers/char/agp/sis-agp.c5
-rw-r--r--drivers/char/agp/via-agp.c13
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c6
-rw-r--r--drivers/pci/bus.c132
-rw-r--r--drivers/pci/host-bridge.c19
-rw-r--r--drivers/pci/probe.c18
-rw-r--r--drivers/pci/quirks.c2
-rw-r--r--drivers/pci/rom.c2
-rw-r--r--drivers/pci/setup-bus.c16
-rw-r--r--drivers/pci/setup-res.c2
-rw-r--r--drivers/pcmcia/i82092.c2
-rw-r--r--drivers/pcmcia/yenta_socket.c6
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.c5
-rw-r--r--drivers/video/arkfb.c2
-rw-r--r--drivers/video/s3fb.c2
-rw-r--r--drivers/video/vt8623fb.c2
-rw-r--r--include/linux/pci.h20
33 files changed, 244 insertions, 195 deletions
diff --git a/arch/alpha/kernel/pci-sysfs.c b/arch/alpha/kernel/pci-sysfs.c
index 2b183b0d3207..99e8d4796c96 100644
--- a/arch/alpha/kernel/pci-sysfs.c
+++ b/arch/alpha/kernel/pci-sysfs.c
@@ -83,7 +83,7 @@ static int pci_mmap_resource(struct kobject *kobj,
83 if (iomem_is_exclusive(res->start)) 83 if (iomem_is_exclusive(res->start))
84 return -EINVAL; 84 return -EINVAL;
85 85
86 pcibios_resource_to_bus(pdev, &bar, res); 86 pcibios_resource_to_bus(pdev->bus, &bar, res);
87 vma->vm_pgoff += bar.start >> (PAGE_SHIFT - (sparse ? 5 : 0)); 87 vma->vm_pgoff += bar.start >> (PAGE_SHIFT - (sparse ? 5 : 0));
88 mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io; 88 mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io;
89 89
@@ -139,7 +139,7 @@ static int sparse_mem_mmap_fits(struct pci_dev *pdev, int num)
139 long dense_offset; 139 long dense_offset;
140 unsigned long sparse_size; 140 unsigned long sparse_size;
141 141
142 pcibios_resource_to_bus(pdev, &bar, &pdev->resource[num]); 142 pcibios_resource_to_bus(pdev->bus, &bar, &pdev->resource[num]);
143 143
144 /* All core logic chips have 4G sparse address space, except 144 /* All core logic chips have 4G sparse address space, except
145 CIA which has 16G (see xxx_SPARSE_MEM and xxx_DENSE_MEM 145 CIA which has 16G (see xxx_SPARSE_MEM and xxx_DENSE_MEM
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index a1e3e40ca3fd..d9476c1fc959 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -835,7 +835,7 @@ static void pcibios_fixup_resources(struct pci_dev *dev)
835 * at 0 as unset as well, except if PCI_PROBE_ONLY is also set 835 * at 0 as unset as well, except if PCI_PROBE_ONLY is also set
836 * since in that case, we don't want to re-assign anything 836 * since in that case, we don't want to re-assign anything
837 */ 837 */
838 pcibios_resource_to_bus(dev, &reg, res); 838 pcibios_resource_to_bus(dev->bus, &reg, res);
839 if (pci_has_flag(PCI_REASSIGN_ALL_RSRC) || 839 if (pci_has_flag(PCI_REASSIGN_ALL_RSRC) ||
840 (reg.start == 0 && !pci_has_flag(PCI_PROBE_ONLY))) { 840 (reg.start == 0 && !pci_has_flag(PCI_PROBE_ONLY))) {
841 /* Only print message if not re-assigning */ 841 /* Only print message if not re-assigning */
@@ -886,7 +886,7 @@ static int pcibios_uninitialized_bridge_resource(struct pci_bus *bus,
886 886
887 /* Job is a bit different between memory and IO */ 887 /* Job is a bit different between memory and IO */
888 if (res->flags & IORESOURCE_MEM) { 888 if (res->flags & IORESOURCE_MEM) {
889 pcibios_resource_to_bus(dev, &region, res); 889 pcibios_resource_to_bus(dev->bus, &region, res);
890 890
891 /* If the BAR is non-0 then it's probably been initialized */ 891 /* If the BAR is non-0 then it's probably been initialized */
892 if (region.start != 0) 892 if (region.start != 0)
diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
index ac0b034f9ae0..83c26d829991 100644
--- a/arch/powerpc/kernel/pci_of_scan.c
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -111,7 +111,7 @@ static void of_pci_parse_addrs(struct device_node *node, struct pci_dev *dev)
111 res->name = pci_name(dev); 111 res->name = pci_name(dev);
112 region.start = base; 112 region.start = base;
113 region.end = base + size - 1; 113 region.end = base + size - 1;
114 pcibios_bus_to_resource(dev, res, &region); 114 pcibios_bus_to_resource(dev->bus, res, &region);
115 } 115 }
116} 116}
117 117
@@ -280,7 +280,7 @@ void of_scan_pci_bridge(struct pci_dev *dev)
280 res->flags = flags; 280 res->flags = flags;
281 region.start = of_read_number(&ranges[1], 2); 281 region.start = of_read_number(&ranges[1], 2);
282 region.end = region.start + size - 1; 282 region.end = region.start + size - 1;
283 pcibios_bus_to_resource(dev, res, &region); 283 pcibios_bus_to_resource(dev->bus, res, &region);
284 } 284 }
285 sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus), 285 sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus),
286 bus->number); 286 bus->number);
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index cb021453de2a..7de8d1f590b7 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -392,7 +392,7 @@ static void apb_fake_ranges(struct pci_dev *dev,
392 res->flags = IORESOURCE_IO; 392 res->flags = IORESOURCE_IO;
393 region.start = (first << 21); 393 region.start = (first << 21);
394 region.end = (last << 21) + ((1 << 21) - 1); 394 region.end = (last << 21) + ((1 << 21) - 1);
395 pcibios_bus_to_resource(dev, res, &region); 395 pcibios_bus_to_resource(dev->bus, res, &region);
396 396
397 pci_read_config_byte(dev, APB_MEM_ADDRESS_MAP, &map); 397 pci_read_config_byte(dev, APB_MEM_ADDRESS_MAP, &map);
398 apb_calc_first_last(map, &first, &last); 398 apb_calc_first_last(map, &first, &last);
@@ -400,7 +400,7 @@ static void apb_fake_ranges(struct pci_dev *dev,
400 res->flags = IORESOURCE_MEM; 400 res->flags = IORESOURCE_MEM;
401 region.start = (first << 29); 401 region.start = (first << 29);
402 region.end = (last << 29) + ((1 << 29) - 1); 402 region.end = (last << 29) + ((1 << 29) - 1);
403 pcibios_bus_to_resource(dev, res, &region); 403 pcibios_bus_to_resource(dev->bus, res, &region);
404} 404}
405 405
406static void pci_of_scan_bus(struct pci_pbm_info *pbm, 406static void pci_of_scan_bus(struct pci_pbm_info *pbm,
@@ -491,7 +491,7 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm,
491 res->flags = flags; 491 res->flags = flags;
492 region.start = GET_64BIT(ranges, 1); 492 region.start = GET_64BIT(ranges, 1);
493 region.end = region.start + size - 1; 493 region.end = region.start + size - 1;
494 pcibios_bus_to_resource(dev, res, &region); 494 pcibios_bus_to_resource(dev->bus, res, &region);
495 } 495 }
496after_ranges: 496after_ranges:
497 sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus), 497 sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus),
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h
index 0de52c5bf9a2..1ac6114c9ea5 100644
--- a/arch/x86/include/asm/pci.h
+++ b/arch/x86/include/asm/pci.h
@@ -125,7 +125,6 @@ int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc,
125 125
126/* generic pci stuff */ 126/* generic pci stuff */
127#include <asm-generic/pci.h> 127#include <asm-generic/pci.h>
128#define PCIBIOS_MAX_MEM_32 0xffffffff
129 128
130#ifdef CONFIG_NUMA 129#ifdef CONFIG_NUMA
131/* Returns the node based on pci bus */ 130/* Returns the node based on pci bus */
diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h
index 923f99df4f1c..b709749c8639 100644
--- a/drivers/char/agp/agp.h
+++ b/drivers/char/agp/agp.h
@@ -239,6 +239,7 @@ long compat_agp_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
239 239
240/* Chipset independent registers (from AGP Spec) */ 240/* Chipset independent registers (from AGP Spec) */
241#define AGP_APBASE 0x10 241#define AGP_APBASE 0x10
242#define AGP_APERTURE_BAR 0
242 243
243#define AGPSTAT 0x4 244#define AGPSTAT 0x4
244#define AGPCMD 0x8 245#define AGPCMD 0x8
diff --git a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c
index 443cd6751ca2..19db03667650 100644
--- a/drivers/char/agp/ali-agp.c
+++ b/drivers/char/agp/ali-agp.c
@@ -85,8 +85,8 @@ static int ali_configure(void)
85 pci_write_config_dword(agp_bridge->dev, ALI_TLBCTRL, ((temp & 0xffffff00) | 0x00000010)); 85 pci_write_config_dword(agp_bridge->dev, ALI_TLBCTRL, ((temp & 0xffffff00) | 0x00000010));
86 86
87 /* address to map to */ 87 /* address to map to */
88 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); 88 agp_bridge->gart_bus_addr = pci_bus_address(agp_bridge->dev,
89 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 89 AGP_APERTURE_BAR);
90 90
91#if 0 91#if 0
92 if (agp_bridge->type == ALI_M1541) { 92 if (agp_bridge->type == ALI_M1541) {
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c
index 779f0ab845a9..3661a51e93e2 100644
--- a/drivers/char/agp/amd-k7-agp.c
+++ b/drivers/char/agp/amd-k7-agp.c
@@ -11,7 +11,7 @@
11#include <linux/slab.h> 11#include <linux/slab.h>
12#include "agp.h" 12#include "agp.h"
13 13
14#define AMD_MMBASE 0x14 14#define AMD_MMBASE_BAR 1
15#define AMD_APSIZE 0xac 15#define AMD_APSIZE 0xac
16#define AMD_MODECNTL 0xb0 16#define AMD_MODECNTL 0xb0
17#define AMD_MODECNTL2 0xb2 17#define AMD_MODECNTL2 0xb2
@@ -126,7 +126,6 @@ static int amd_create_gatt_table(struct agp_bridge_data *bridge)
126 unsigned long __iomem *cur_gatt; 126 unsigned long __iomem *cur_gatt;
127 unsigned long addr; 127 unsigned long addr;
128 int retval; 128 int retval;
129 u32 temp;
130 int i; 129 int i;
131 130
132 value = A_SIZE_LVL2(agp_bridge->current_size); 131 value = A_SIZE_LVL2(agp_bridge->current_size);
@@ -149,8 +148,7 @@ static int amd_create_gatt_table(struct agp_bridge_data *bridge)
149 * used to program the agp master not the cpu 148 * used to program the agp master not the cpu
150 */ 149 */
151 150
152 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); 151 addr = pci_bus_address(agp_bridge->dev, AGP_APERTURE_BAR);
153 addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
154 agp_bridge->gart_bus_addr = addr; 152 agp_bridge->gart_bus_addr = addr;
155 153
156 /* Calculate the agp offset */ 154 /* Calculate the agp offset */
@@ -207,6 +205,7 @@ static int amd_irongate_fetch_size(void)
207static int amd_irongate_configure(void) 205static int amd_irongate_configure(void)
208{ 206{
209 struct aper_size_info_lvl2 *current_size; 207 struct aper_size_info_lvl2 *current_size;
208 phys_addr_t reg;
210 u32 temp; 209 u32 temp;
211 u16 enable_reg; 210 u16 enable_reg;
212 211
@@ -214,9 +213,8 @@ static int amd_irongate_configure(void)
214 213
215 if (!amd_irongate_private.registers) { 214 if (!amd_irongate_private.registers) {
216 /* Get the memory mapped registers */ 215 /* Get the memory mapped registers */
217 pci_read_config_dword(agp_bridge->dev, AMD_MMBASE, &temp); 216 reg = pci_resource_start(agp_bridge->dev, AMD_MMBASE_BAR);
218 temp = (temp & PCI_BASE_ADDRESS_MEM_MASK); 217 amd_irongate_private.registers = (volatile u8 __iomem *) ioremap(reg, 4096);
219 amd_irongate_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096);
220 if (!amd_irongate_private.registers) 218 if (!amd_irongate_private.registers)
221 return -ENOMEM; 219 return -ENOMEM;
222 } 220 }
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index d79d692d05b8..95326ac610f6 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -269,7 +269,6 @@ static int agp_aperture_valid(u64 aper, u32 size)
269 */ 269 */
270static int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp, u16 cap) 270static int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp, u16 cap)
271{ 271{
272 u32 aper_low, aper_hi;
273 u64 aper, nb_aper; 272 u64 aper, nb_aper;
274 int order = 0; 273 int order = 0;
275 u32 nb_order, nb_base; 274 u32 nb_order, nb_base;
@@ -295,9 +294,7 @@ static int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp, u16 cap)
295 apsize |= 0xf00; 294 apsize |= 0xf00;
296 order = 7 - hweight16(apsize); 295 order = 7 - hweight16(apsize);
297 296
298 pci_read_config_dword(agp, 0x10, &aper_low); 297 aper = pci_bus_address(agp, AGP_APERTURE_BAR);
299 pci_read_config_dword(agp, 0x14, &aper_hi);
300 aper = (aper_low & ~((1<<22)-1)) | ((u64)aper_hi << 32);
301 298
302 /* 299 /*
303 * On some sick chips APSIZE is 0. This means it wants 4G 300 * On some sick chips APSIZE is 0. This means it wants 4G
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
index 03c1dc1ab552..18a7a6baa304 100644
--- a/drivers/char/agp/ati-agp.c
+++ b/drivers/char/agp/ati-agp.c
@@ -12,7 +12,7 @@
12#include <asm/agp.h> 12#include <asm/agp.h>
13#include "agp.h" 13#include "agp.h"
14 14
15#define ATI_GART_MMBASE_ADDR 0x14 15#define ATI_GART_MMBASE_BAR 1
16#define ATI_RS100_APSIZE 0xac 16#define ATI_RS100_APSIZE 0xac
17#define ATI_RS100_IG_AGPMODE 0xb0 17#define ATI_RS100_IG_AGPMODE 0xb0
18#define ATI_RS300_APSIZE 0xf8 18#define ATI_RS300_APSIZE 0xf8
@@ -196,12 +196,12 @@ static void ati_cleanup(void)
196 196
197static int ati_configure(void) 197static int ati_configure(void)
198{ 198{
199 phys_addr_t reg;
199 u32 temp; 200 u32 temp;
200 201
201 /* Get the memory mapped registers */ 202 /* Get the memory mapped registers */
202 pci_read_config_dword(agp_bridge->dev, ATI_GART_MMBASE_ADDR, &temp); 203 reg = pci_resource_start(agp_bridge->dev, ATI_GART_MMBASE_BAR);
203 temp = (temp & 0xfffff000); 204 ati_generic_private.registers = (volatile u8 __iomem *) ioremap(reg, 4096);
204 ati_generic_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096);
205 205
206 if (!ati_generic_private.registers) 206 if (!ati_generic_private.registers)
207 return -ENOMEM; 207 return -ENOMEM;
@@ -211,18 +211,18 @@ static int ati_configure(void)
211 else 211 else
212 pci_write_config_dword(agp_bridge->dev, ATI_RS300_IG_AGPMODE, 0x20000); 212 pci_write_config_dword(agp_bridge->dev, ATI_RS300_IG_AGPMODE, 0x20000);
213 213
214 /* address to map too */ 214 /* address to map to */
215 /* 215 /*
216 pci_read_config_dword(agp_bridge.dev, AGP_APBASE, &temp); 216 agp_bridge.gart_bus_addr = pci_bus_address(agp_bridge.dev,
217 agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 217 AGP_APERTURE_BAR);
218 printk(KERN_INFO PFX "IGP320 gart_bus_addr: %x\n", agp_bridge.gart_bus_addr); 218 printk(KERN_INFO PFX "IGP320 gart_bus_addr: %x\n", agp_bridge.gart_bus_addr);
219 */ 219 */
220 writel(0x60000, ati_generic_private.registers+ATI_GART_FEATURE_ID); 220 writel(0x60000, ati_generic_private.registers+ATI_GART_FEATURE_ID);
221 readl(ati_generic_private.registers+ATI_GART_FEATURE_ID); /* PCI Posting.*/ 221 readl(ati_generic_private.registers+ATI_GART_FEATURE_ID); /* PCI Posting.*/
222 222
223 /* SIGNALED_SYSTEM_ERROR @ NB_STATUS */ 223 /* SIGNALED_SYSTEM_ERROR @ NB_STATUS */
224 pci_read_config_dword(agp_bridge->dev, 4, &temp); 224 pci_read_config_dword(agp_bridge->dev, PCI_COMMAND, &temp);
225 pci_write_config_dword(agp_bridge->dev, 4, temp | (1<<14)); 225 pci_write_config_dword(agp_bridge->dev, PCI_COMMAND, temp | (1<<14));
226 226
227 /* Write out the address of the gatt table */ 227 /* Write out the address of the gatt table */
228 writel(agp_bridge->gatt_bus_addr, ati_generic_private.registers+ATI_GART_BASE); 228 writel(agp_bridge->gatt_bus_addr, ati_generic_private.registers+ATI_GART_BASE);
@@ -385,8 +385,7 @@ static int ati_create_gatt_table(struct agp_bridge_data *bridge)
385 * This is a bus address even on the alpha, b/c its 385 * This is a bus address even on the alpha, b/c its
386 * used to program the agp master not the cpu 386 * used to program the agp master not the cpu
387 */ 387 */
388 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); 388 addr = pci_bus_address(agp_bridge->dev, AGP_APERTURE_BAR);
389 addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
390 agp_bridge->gart_bus_addr = addr; 389 agp_bridge->gart_bus_addr = addr;
391 390
392 /* Calculate the agp offset */ 391 /* Calculate the agp offset */
diff --git a/drivers/char/agp/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c
index 6974d5032053..533cb6d229b8 100644
--- a/drivers/char/agp/efficeon-agp.c
+++ b/drivers/char/agp/efficeon-agp.c
@@ -128,7 +128,6 @@ static void efficeon_cleanup(void)
128 128
129static int efficeon_configure(void) 129static int efficeon_configure(void)
130{ 130{
131 u32 temp;
132 u16 temp2; 131 u16 temp2;
133 struct aper_size_info_lvl2 *current_size; 132 struct aper_size_info_lvl2 *current_size;
134 133
@@ -141,8 +140,8 @@ static int efficeon_configure(void)
141 current_size->size_value); 140 current_size->size_value);
142 141
143 /* address to map to */ 142 /* address to map to */
144 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); 143 agp_bridge->gart_bus_addr = pci_bus_address(agp_bridge->dev,
145 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 144 AGP_APERTURE_BAR);
146 145
147 /* agpctrl */ 146 /* agpctrl */
148 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2280); 147 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2280);
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index a0df182f6f7d..f39437addb58 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -1396,8 +1396,8 @@ int agp3_generic_configure(void)
1396 1396
1397 current_size = A_SIZE_16(agp_bridge->current_size); 1397 current_size = A_SIZE_16(agp_bridge->current_size);
1398 1398
1399 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); 1399 agp_bridge->gart_bus_addr = pci_bus_address(agp_bridge->dev,
1400 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 1400 AGP_APERTURE_BAR);
1401 1401
1402 /* set aperture size */ 1402 /* set aperture size */
1403 pci_write_config_word(agp_bridge->dev, agp_bridge->capndx+AGPAPSIZE, current_size->size_value); 1403 pci_write_config_word(agp_bridge->dev, agp_bridge->capndx+AGPAPSIZE, current_size->size_value);
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index a426ee1f57a6..a7c276585a9f 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -118,7 +118,6 @@ static void intel_8xx_cleanup(void)
118 118
119static int intel_configure(void) 119static int intel_configure(void)
120{ 120{
121 u32 temp;
122 u16 temp2; 121 u16 temp2;
123 struct aper_size_info_16 *current_size; 122 struct aper_size_info_16 *current_size;
124 123
@@ -128,8 +127,8 @@ static int intel_configure(void)
128 pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 127 pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
129 128
130 /* address to map to */ 129 /* address to map to */
131 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); 130 agp_bridge->gart_bus_addr = pci_bus_address(agp_bridge->dev,
132 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 131 AGP_APERTURE_BAR);
133 132
134 /* attbase - aperture base */ 133 /* attbase - aperture base */
135 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); 134 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
@@ -148,7 +147,7 @@ static int intel_configure(void)
148 147
149static int intel_815_configure(void) 148static int intel_815_configure(void)
150{ 149{
151 u32 temp, addr; 150 u32 addr;
152 u8 temp2; 151 u8 temp2;
153 struct aper_size_info_8 *current_size; 152 struct aper_size_info_8 *current_size;
154 153
@@ -167,8 +166,8 @@ static int intel_815_configure(void)
167 current_size->size_value); 166 current_size->size_value);
168 167
169 /* address to map to */ 168 /* address to map to */
170 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); 169 agp_bridge->gart_bus_addr = pci_bus_address(agp_bridge->dev,
171 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 170 AGP_APERTURE_BAR);
172 171
173 pci_read_config_dword(agp_bridge->dev, INTEL_ATTBASE, &addr); 172 pci_read_config_dword(agp_bridge->dev, INTEL_ATTBASE, &addr);
174 addr &= INTEL_815_ATTBASE_MASK; 173 addr &= INTEL_815_ATTBASE_MASK;
@@ -208,7 +207,6 @@ static void intel_820_cleanup(void)
208 207
209static int intel_820_configure(void) 208static int intel_820_configure(void)
210{ 209{
211 u32 temp;
212 u8 temp2; 210 u8 temp2;
213 struct aper_size_info_8 *current_size; 211 struct aper_size_info_8 *current_size;
214 212
@@ -218,8 +216,8 @@ static int intel_820_configure(void)
218 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 216 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
219 217
220 /* address to map to */ 218 /* address to map to */
221 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); 219 agp_bridge->gart_bus_addr = pci_bus_address(agp_bridge->dev,
222 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 220 AGP_APERTURE_BAR);
223 221
224 /* attbase - aperture base */ 222 /* attbase - aperture base */
225 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); 223 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
@@ -239,7 +237,6 @@ static int intel_820_configure(void)
239 237
240static int intel_840_configure(void) 238static int intel_840_configure(void)
241{ 239{
242 u32 temp;
243 u16 temp2; 240 u16 temp2;
244 struct aper_size_info_8 *current_size; 241 struct aper_size_info_8 *current_size;
245 242
@@ -249,8 +246,8 @@ static int intel_840_configure(void)
249 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 246 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
250 247
251 /* address to map to */ 248 /* address to map to */
252 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); 249 agp_bridge->gart_bus_addr = pci_bus_address(agp_bridge->dev,
253 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 250 AGP_APERTURE_BAR);
254 251
255 /* attbase - aperture base */ 252 /* attbase - aperture base */
256 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); 253 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
@@ -268,7 +265,6 @@ static int intel_840_configure(void)
268 265
269static int intel_845_configure(void) 266static int intel_845_configure(void)
270{ 267{
271 u32 temp;
272 u8 temp2; 268 u8 temp2;
273 struct aper_size_info_8 *current_size; 269 struct aper_size_info_8 *current_size;
274 270
@@ -282,9 +278,9 @@ static int intel_845_configure(void)
282 agp_bridge->apbase_config); 278 agp_bridge->apbase_config);
283 } else { 279 } else {
284 /* address to map to */ 280 /* address to map to */
285 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); 281 agp_bridge->gart_bus_addr = pci_bus_address(agp_bridge->dev,
286 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 282 AGP_APERTURE_BAR);
287 agp_bridge->apbase_config = temp; 283 agp_bridge->apbase_config = agp_bridge->gart_bus_addr;
288 } 284 }
289 285
290 /* attbase - aperture base */ 286 /* attbase - aperture base */
@@ -303,7 +299,6 @@ static int intel_845_configure(void)
303 299
304static int intel_850_configure(void) 300static int intel_850_configure(void)
305{ 301{
306 u32 temp;
307 u16 temp2; 302 u16 temp2;
308 struct aper_size_info_8 *current_size; 303 struct aper_size_info_8 *current_size;
309 304
@@ -313,8 +308,8 @@ static int intel_850_configure(void)
313 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 308 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
314 309
315 /* address to map to */ 310 /* address to map to */
316 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); 311 agp_bridge->gart_bus_addr = pci_bus_address(agp_bridge->dev,
317 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 312 AGP_APERTURE_BAR);
318 313
319 /* attbase - aperture base */ 314 /* attbase - aperture base */
320 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); 315 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
@@ -332,7 +327,6 @@ static int intel_850_configure(void)
332 327
333static int intel_860_configure(void) 328static int intel_860_configure(void)
334{ 329{
335 u32 temp;
336 u16 temp2; 330 u16 temp2;
337 struct aper_size_info_8 *current_size; 331 struct aper_size_info_8 *current_size;
338 332
@@ -342,8 +336,8 @@ static int intel_860_configure(void)
342 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 336 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
343 337
344 /* address to map to */ 338 /* address to map to */
345 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); 339 agp_bridge->gart_bus_addr = pci_bus_address(agp_bridge->dev,
346 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 340 AGP_APERTURE_BAR);
347 341
348 /* attbase - aperture base */ 342 /* attbase - aperture base */
349 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); 343 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
@@ -361,7 +355,6 @@ static int intel_860_configure(void)
361 355
362static int intel_830mp_configure(void) 356static int intel_830mp_configure(void)
363{ 357{
364 u32 temp;
365 u16 temp2; 358 u16 temp2;
366 struct aper_size_info_8 *current_size; 359 struct aper_size_info_8 *current_size;
367 360
@@ -371,8 +364,8 @@ static int intel_830mp_configure(void)
371 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 364 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
372 365
373 /* address to map to */ 366 /* address to map to */
374 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); 367 agp_bridge->gart_bus_addr = pci_bus_address(agp_bridge->dev,
375 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 368 AGP_APERTURE_BAR);
376 369
377 /* attbase - aperture base */ 370 /* attbase - aperture base */
378 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); 371 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
@@ -390,7 +383,6 @@ static int intel_830mp_configure(void)
390 383
391static int intel_7505_configure(void) 384static int intel_7505_configure(void)
392{ 385{
393 u32 temp;
394 u16 temp2; 386 u16 temp2;
395 struct aper_size_info_8 *current_size; 387 struct aper_size_info_8 *current_size;
396 388
@@ -400,8 +392,8 @@ static int intel_7505_configure(void)
400 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 392 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
401 393
402 /* address to map to */ 394 /* address to map to */
403 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); 395 agp_bridge->gart_bus_addr = pci_bus_address(agp_bridge->dev,
404 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 396 AGP_APERTURE_BAR);
405 397
406 /* attbase - aperture base */ 398 /* attbase - aperture base */
407 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); 399 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
diff --git a/drivers/char/agp/intel-agp.h b/drivers/char/agp/intel-agp.h
index 1042c1b90376..fda073dcd967 100644
--- a/drivers/char/agp/intel-agp.h
+++ b/drivers/char/agp/intel-agp.h
@@ -55,8 +55,8 @@
55#define INTEL_I860_ERRSTS 0xc8 55#define INTEL_I860_ERRSTS 0xc8
56 56
57/* Intel i810 registers */ 57/* Intel i810 registers */
58#define I810_GMADDR 0x10 58#define I810_GMADR_BAR 0
59#define I810_MMADDR 0x14 59#define I810_MMADR_BAR 1
60#define I810_PTE_BASE 0x10000 60#define I810_PTE_BASE 0x10000
61#define I810_PTE_MAIN_UNCACHED 0x00000000 61#define I810_PTE_MAIN_UNCACHED 0x00000000
62#define I810_PTE_LOCAL 0x00000002 62#define I810_PTE_LOCAL 0x00000002
@@ -113,9 +113,9 @@
113#define INTEL_I850_ERRSTS 0xc8 113#define INTEL_I850_ERRSTS 0xc8
114 114
115/* intel 915G registers */ 115/* intel 915G registers */
116#define I915_GMADDR 0x18 116#define I915_GMADR_BAR 2
117#define I915_MMADDR 0x10 117#define I915_MMADR_BAR 0
118#define I915_PTEADDR 0x1C 118#define I915_PTE_BAR 3
119#define I915_GMCH_GMS_STOLEN_48M (0x6 << 4) 119#define I915_GMCH_GMS_STOLEN_48M (0x6 << 4)
120#define I915_GMCH_GMS_STOLEN_64M (0x7 << 4) 120#define I915_GMCH_GMS_STOLEN_64M (0x7 << 4)
121#define G33_GMCH_GMS_STOLEN_128M (0x8 << 4) 121#define G33_GMCH_GMS_STOLEN_128M (0x8 << 4)
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index b8e2014cb9cb..ad5da1ffcbe9 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -64,7 +64,7 @@ static struct _intel_private {
64 struct pci_dev *pcidev; /* device one */ 64 struct pci_dev *pcidev; /* device one */
65 struct pci_dev *bridge_dev; 65 struct pci_dev *bridge_dev;
66 u8 __iomem *registers; 66 u8 __iomem *registers;
67 phys_addr_t gtt_bus_addr; 67 phys_addr_t gtt_phys_addr;
68 u32 PGETBL_save; 68 u32 PGETBL_save;
69 u32 __iomem *gtt; /* I915G */ 69 u32 __iomem *gtt; /* I915G */
70 bool clear_fake_agp; /* on first access via agp, fill with scratch */ 70 bool clear_fake_agp; /* on first access via agp, fill with scratch */
@@ -172,7 +172,7 @@ static void i8xx_destroy_pages(struct page *page)
172#define I810_GTT_ORDER 4 172#define I810_GTT_ORDER 4
173static int i810_setup(void) 173static int i810_setup(void)
174{ 174{
175 u32 reg_addr; 175 phys_addr_t reg_addr;
176 char *gtt_table; 176 char *gtt_table;
177 177
178 /* i81x does not preallocate the gtt. It's always 64kb in size. */ 178 /* i81x does not preallocate the gtt. It's always 64kb in size. */
@@ -181,8 +181,7 @@ static int i810_setup(void)
181 return -ENOMEM; 181 return -ENOMEM;
182 intel_private.i81x_gtt_table = gtt_table; 182 intel_private.i81x_gtt_table = gtt_table;
183 183
184 pci_read_config_dword(intel_private.pcidev, I810_MMADDR, &reg_addr); 184 reg_addr = pci_resource_start(intel_private.pcidev, I810_MMADR_BAR);
185 reg_addr &= 0xfff80000;
186 185
187 intel_private.registers = ioremap(reg_addr, KB(64)); 186 intel_private.registers = ioremap(reg_addr, KB(64));
188 if (!intel_private.registers) 187 if (!intel_private.registers)
@@ -191,7 +190,7 @@ static int i810_setup(void)
191 writel(virt_to_phys(gtt_table) | I810_PGETBL_ENABLED, 190 writel(virt_to_phys(gtt_table) | I810_PGETBL_ENABLED,
192 intel_private.registers+I810_PGETBL_CTL); 191 intel_private.registers+I810_PGETBL_CTL);
193 192
194 intel_private.gtt_bus_addr = reg_addr + I810_PTE_BASE; 193 intel_private.gtt_phys_addr = reg_addr + I810_PTE_BASE;
195 194
196 if ((readl(intel_private.registers+I810_DRAM_CTL) 195 if ((readl(intel_private.registers+I810_DRAM_CTL)
197 & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) { 196 & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) {
@@ -608,9 +607,8 @@ static bool intel_gtt_can_wc(void)
608 607
609static int intel_gtt_init(void) 608static int intel_gtt_init(void)
610{ 609{
611 u32 gma_addr;
612 u32 gtt_map_size; 610 u32 gtt_map_size;
613 int ret; 611 int ret, bar;
614 612
615 ret = intel_private.driver->setup(); 613 ret = intel_private.driver->setup();
616 if (ret != 0) 614 if (ret != 0)
@@ -636,10 +634,10 @@ static int intel_gtt_init(void)
636 634
637 intel_private.gtt = NULL; 635 intel_private.gtt = NULL;
638 if (intel_gtt_can_wc()) 636 if (intel_gtt_can_wc())
639 intel_private.gtt = ioremap_wc(intel_private.gtt_bus_addr, 637 intel_private.gtt = ioremap_wc(intel_private.gtt_phys_addr,
640 gtt_map_size); 638 gtt_map_size);
641 if (intel_private.gtt == NULL) 639 if (intel_private.gtt == NULL)
642 intel_private.gtt = ioremap(intel_private.gtt_bus_addr, 640 intel_private.gtt = ioremap(intel_private.gtt_phys_addr,
643 gtt_map_size); 641 gtt_map_size);
644 if (intel_private.gtt == NULL) { 642 if (intel_private.gtt == NULL) {
645 intel_private.driver->cleanup(); 643 intel_private.driver->cleanup();
@@ -660,14 +658,11 @@ static int intel_gtt_init(void)
660 } 658 }
661 659
662 if (INTEL_GTT_GEN <= 2) 660 if (INTEL_GTT_GEN <= 2)
663 pci_read_config_dword(intel_private.pcidev, I810_GMADDR, 661 bar = I810_GMADR_BAR;
664 &gma_addr);
665 else 662 else
666 pci_read_config_dword(intel_private.pcidev, I915_GMADDR, 663 bar = I915_GMADR_BAR;
667 &gma_addr);
668
669 intel_private.gma_bus_addr = (gma_addr & PCI_BASE_ADDRESS_MEM_MASK);
670 664
665 intel_private.gma_bus_addr = pci_bus_address(intel_private.pcidev, bar);
671 return 0; 666 return 0;
672} 667}
673 668
@@ -787,16 +782,15 @@ EXPORT_SYMBOL(intel_enable_gtt);
787 782
788static int i830_setup(void) 783static int i830_setup(void)
789{ 784{
790 u32 reg_addr; 785 phys_addr_t reg_addr;
791 786
792 pci_read_config_dword(intel_private.pcidev, I810_MMADDR, &reg_addr); 787 reg_addr = pci_resource_start(intel_private.pcidev, I810_MMADR_BAR);
793 reg_addr &= 0xfff80000;
794 788
795 intel_private.registers = ioremap(reg_addr, KB(64)); 789 intel_private.registers = ioremap(reg_addr, KB(64));
796 if (!intel_private.registers) 790 if (!intel_private.registers)
797 return -ENOMEM; 791 return -ENOMEM;
798 792
799 intel_private.gtt_bus_addr = reg_addr + I810_PTE_BASE; 793 intel_private.gtt_phys_addr = reg_addr + I810_PTE_BASE;
800 794
801 return 0; 795 return 0;
802} 796}
@@ -1108,12 +1102,10 @@ static void i965_write_entry(dma_addr_t addr,
1108 1102
1109static int i9xx_setup(void) 1103static int i9xx_setup(void)
1110{ 1104{
1111 u32 reg_addr, gtt_addr; 1105 phys_addr_t reg_addr;
1112 int size = KB(512); 1106 int size = KB(512);
1113 1107
1114 pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &reg_addr); 1108 reg_addr = pci_resource_start(intel_private.pcidev, I915_MMADR_BAR);
1115
1116 reg_addr &= 0xfff80000;
1117 1109
1118 intel_private.registers = ioremap(reg_addr, size); 1110 intel_private.registers = ioremap(reg_addr, size);
1119 if (!intel_private.registers) 1111 if (!intel_private.registers)
@@ -1121,15 +1113,14 @@ static int i9xx_setup(void)
1121 1113
1122 switch (INTEL_GTT_GEN) { 1114 switch (INTEL_GTT_GEN) {
1123 case 3: 1115 case 3:
1124 pci_read_config_dword(intel_private.pcidev, 1116 intel_private.gtt_phys_addr =
1125 I915_PTEADDR, &gtt_addr); 1117 pci_resource_start(intel_private.pcidev, I915_PTE_BAR);
1126 intel_private.gtt_bus_addr = gtt_addr;
1127 break; 1118 break;
1128 case 5: 1119 case 5:
1129 intel_private.gtt_bus_addr = reg_addr + MB(2); 1120 intel_private.gtt_phys_addr = reg_addr + MB(2);
1130 break; 1121 break;
1131 default: 1122 default:
1132 intel_private.gtt_bus_addr = reg_addr + KB(512); 1123 intel_private.gtt_phys_addr = reg_addr + KB(512);
1133 break; 1124 break;
1134 } 1125 }
1135 1126
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index be42a2312dc9..a1861b75eb31 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -106,6 +106,7 @@ static int nvidia_configure(void)
106{ 106{
107 int i, rc, num_dirs; 107 int i, rc, num_dirs;
108 u32 apbase, aplimit; 108 u32 apbase, aplimit;
109 phys_addr_t apbase_phys;
109 struct aper_size_info_8 *current_size; 110 struct aper_size_info_8 *current_size;
110 u32 temp; 111 u32 temp;
111 112
@@ -115,9 +116,8 @@ static int nvidia_configure(void)
115 pci_write_config_byte(agp_bridge->dev, NVIDIA_0_APSIZE, 116 pci_write_config_byte(agp_bridge->dev, NVIDIA_0_APSIZE,
116 current_size->size_value); 117 current_size->size_value);
117 118
118 /* address to map to */ 119 /* address to map to */
119 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &apbase); 120 apbase = pci_bus_address(agp_bridge->dev, AGP_APERTURE_BAR);
120 apbase &= PCI_BASE_ADDRESS_MEM_MASK;
121 agp_bridge->gart_bus_addr = apbase; 121 agp_bridge->gart_bus_addr = apbase;
122 aplimit = apbase + (current_size->size * 1024 * 1024) - 1; 122 aplimit = apbase + (current_size->size * 1024 * 1024) - 1;
123 pci_write_config_dword(nvidia_private.dev_2, NVIDIA_2_APBASE, apbase); 123 pci_write_config_dword(nvidia_private.dev_2, NVIDIA_2_APBASE, apbase);
@@ -153,8 +153,9 @@ static int nvidia_configure(void)
153 pci_write_config_dword(agp_bridge->dev, NVIDIA_0_APSIZE, temp | 0x100); 153 pci_write_config_dword(agp_bridge->dev, NVIDIA_0_APSIZE, temp | 0x100);
154 154
155 /* map aperture */ 155 /* map aperture */
156 apbase_phys = pci_resource_start(agp_bridge->dev, AGP_APERTURE_BAR);
156 nvidia_private.aperture = 157 nvidia_private.aperture =
157 (volatile u32 __iomem *) ioremap(apbase, 33 * PAGE_SIZE); 158 (volatile u32 __iomem *) ioremap(apbase_phys, 33 * PAGE_SIZE);
158 159
159 if (!nvidia_private.aperture) 160 if (!nvidia_private.aperture)
160 return -ENOMEM; 161 return -ENOMEM;
diff --git a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c
index 79c838c434bc..2c74038da459 100644
--- a/drivers/char/agp/sis-agp.c
+++ b/drivers/char/agp/sis-agp.c
@@ -50,13 +50,12 @@ static void sis_tlbflush(struct agp_memory *mem)
50 50
51static int sis_configure(void) 51static int sis_configure(void)
52{ 52{
53 u32 temp;
54 struct aper_size_info_8 *current_size; 53 struct aper_size_info_8 *current_size;
55 54
56 current_size = A_SIZE_8(agp_bridge->current_size); 55 current_size = A_SIZE_8(agp_bridge->current_size);
57 pci_write_config_byte(agp_bridge->dev, SIS_TLBCNTRL, 0x05); 56 pci_write_config_byte(agp_bridge->dev, SIS_TLBCNTRL, 0x05);
58 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); 57 agp_bridge->gart_bus_addr = pci_bus_address(agp_bridge->dev,
59 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 58 AGP_APERTURE_BAR);
60 pci_write_config_dword(agp_bridge->dev, SIS_ATTBASE, 59 pci_write_config_dword(agp_bridge->dev, SIS_ATTBASE,
61 agp_bridge->gatt_bus_addr); 60 agp_bridge->gatt_bus_addr);
62 pci_write_config_byte(agp_bridge->dev, SIS_APSIZE, 61 pci_write_config_byte(agp_bridge->dev, SIS_APSIZE,
diff --git a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c
index 74d3aa3773bf..228f20cddc05 100644
--- a/drivers/char/agp/via-agp.c
+++ b/drivers/char/agp/via-agp.c
@@ -43,16 +43,15 @@ static int via_fetch_size(void)
43 43
44static int via_configure(void) 44static int via_configure(void)
45{ 45{
46 u32 temp;
47 struct aper_size_info_8 *current_size; 46 struct aper_size_info_8 *current_size;
48 47
49 current_size = A_SIZE_8(agp_bridge->current_size); 48 current_size = A_SIZE_8(agp_bridge->current_size);
50 /* aperture size */ 49 /* aperture size */
51 pci_write_config_byte(agp_bridge->dev, VIA_APSIZE, 50 pci_write_config_byte(agp_bridge->dev, VIA_APSIZE,
52 current_size->size_value); 51 current_size->size_value);
53 /* address to map too */ 52 /* address to map to */
54 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); 53 agp_bridge->gart_bus_addr = pci_bus_address(agp_bridge->dev,
55 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 54 AGP_APERTURE_BAR);
56 55
57 /* GART control register */ 56 /* GART control register */
58 pci_write_config_dword(agp_bridge->dev, VIA_GARTCTRL, 0x0000000f); 57 pci_write_config_dword(agp_bridge->dev, VIA_GARTCTRL, 0x0000000f);
@@ -132,9 +131,9 @@ static int via_configure_agp3(void)
132 131
133 current_size = A_SIZE_16(agp_bridge->current_size); 132 current_size = A_SIZE_16(agp_bridge->current_size);
134 133
135 /* address to map too */ 134 /* address to map to */
136 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); 135 agp_bridge->gart_bus_addr = pci_bus_address(agp_bridge->dev,
137 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 136 AGP_APERTURE_BAR);
138 137
139 /* attbase - aperture GATT base */ 138 /* attbase - aperture GATT base */
140 pci_write_config_dword(agp_bridge->dev, VIA_AGP3_ATTBASE, 139 pci_write_config_dword(agp_bridge->dev, VIA_AGP3_ATTBASE,
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 3620a1b0a73c..15604b3dda3e 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -1260,14 +1260,14 @@ static int ggtt_probe_common(struct drm_device *dev,
1260 size_t gtt_size) 1260 size_t gtt_size)
1261{ 1261{
1262 struct drm_i915_private *dev_priv = dev->dev_private; 1262 struct drm_i915_private *dev_priv = dev->dev_private;
1263 phys_addr_t gtt_bus_addr; 1263 phys_addr_t gtt_phys_addr;
1264 int ret; 1264 int ret;
1265 1265
1266 /* For Modern GENs the PTEs and register space are split in the BAR */ 1266 /* For Modern GENs the PTEs and register space are split in the BAR */
1267 gtt_bus_addr = pci_resource_start(dev->pdev, 0) + 1267 gtt_phys_addr = pci_resource_start(dev->pdev, 0) +
1268 (pci_resource_len(dev->pdev, 0) / 2); 1268 (pci_resource_len(dev->pdev, 0) / 2);
1269 1269
1270 dev_priv->gtt.gsm = ioremap_wc(gtt_bus_addr, gtt_size); 1270 dev_priv->gtt.gsm = ioremap_wc(gtt_phys_addr, gtt_size);
1271 if (!dev_priv->gtt.gsm) { 1271 if (!dev_priv->gtt.gsm) {
1272 DRM_ERROR("Failed to map the gtt page table\n"); 1272 DRM_ERROR("Failed to map the gtt page table\n");
1273 return -ENOMEM; 1273 return -ENOMEM;
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index a037d81f21ed..00660cc502c5 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -98,41 +98,54 @@ void pci_bus_remove_resources(struct pci_bus *bus)
98 } 98 }
99} 99}
100 100
101/** 101static struct pci_bus_region pci_32_bit = {0, 0xffffffffULL};
102 * pci_bus_alloc_resource - allocate a resource from a parent bus 102#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
103 * @bus: PCI bus 103static struct pci_bus_region pci_64_bit = {0,
104 * @res: resource to allocate 104 (dma_addr_t) 0xffffffffffffffffULL};
105 * @size: size of resource to allocate 105static struct pci_bus_region pci_high = {(dma_addr_t) 0x100000000ULL,
106 * @align: alignment of resource to allocate 106 (dma_addr_t) 0xffffffffffffffffULL};
107 * @min: minimum /proc/iomem address to allocate 107#endif
108 * @type_mask: IORESOURCE_* type flags 108
109 * @alignf: resource alignment function 109/*
110 * @alignf_data: data argument for resource alignment function 110 * @res contains CPU addresses. Clip it so the corresponding bus addresses
111 * 111 * on @bus are entirely within @region. This is used to control the bus
112 * Given the PCI bus a device resides on, the size, minimum address, 112 * addresses of resources we allocate, e.g., we may need a resource that
113 * alignment and type, try to find an acceptable resource allocation 113 * can be mapped by a 32-bit BAR.
114 * for a specific device resource.
115 */ 114 */
116int 115static void pci_clip_resource_to_region(struct pci_bus *bus,
117pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, 116 struct resource *res,
117 struct pci_bus_region *region)
118{
119 struct pci_bus_region r;
120
121 pcibios_resource_to_bus(bus, &r, res);
122 if (r.start < region->start)
123 r.start = region->start;
124 if (r.end > region->end)
125 r.end = region->end;
126
127 if (r.end < r.start)
128 res->end = res->start - 1;
129 else
130 pcibios_bus_to_resource(bus, res, &r);
131}
132
133static int pci_bus_alloc_from_region(struct pci_bus *bus, struct resource *res,
118 resource_size_t size, resource_size_t align, 134 resource_size_t size, resource_size_t align,
119 resource_size_t min, unsigned int type_mask, 135 resource_size_t min, unsigned int type_mask,
120 resource_size_t (*alignf)(void *, 136 resource_size_t (*alignf)(void *,
121 const struct resource *, 137 const struct resource *,
122 resource_size_t, 138 resource_size_t,
123 resource_size_t), 139 resource_size_t),
124 void *alignf_data) 140 void *alignf_data,
141 struct pci_bus_region *region)
125{ 142{
126 int i, ret = -ENOMEM; 143 int i, ret;
127 struct resource *r; 144 struct resource *r, avail;
128 resource_size_t max = -1; 145 resource_size_t max;
129 146
130 type_mask |= IORESOURCE_IO | IORESOURCE_MEM; 147 type_mask |= IORESOURCE_IO | IORESOURCE_MEM;
131 148
132 /* don't allocate too high if the pref mem doesn't support 64bit*/
133 if (!(res->flags & IORESOURCE_MEM_64))
134 max = PCIBIOS_MAX_MEM_32;
135
136 pci_bus_for_each_resource(bus, r, i) { 149 pci_bus_for_each_resource(bus, r, i) {
137 if (!r) 150 if (!r)
138 continue; 151 continue;
@@ -147,15 +160,74 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
147 !(res->flags & IORESOURCE_PREFETCH)) 160 !(res->flags & IORESOURCE_PREFETCH))
148 continue; 161 continue;
149 162
163 avail = *r;
164 pci_clip_resource_to_region(bus, &avail, region);
165 if (!resource_size(&avail))
166 continue;
167
168 /*
169 * "min" is typically PCIBIOS_MIN_IO or PCIBIOS_MIN_MEM to
170 * protect badly documented motherboard resources, but if
171 * this is an already-configured bridge window, its start
172 * overrides "min".
173 */
174 if (avail.start)
175 min = avail.start;
176
177 max = avail.end;
178
150 /* Ok, try it out.. */ 179 /* Ok, try it out.. */
151 ret = allocate_resource(r, res, size, 180 ret = allocate_resource(r, res, size, min, max,
152 r->start ? : min, 181 align, alignf, alignf_data);
153 max, align,
154 alignf, alignf_data);
155 if (ret == 0) 182 if (ret == 0)
156 break; 183 return 0;
157 } 184 }
158 return ret; 185 return -ENOMEM;
186}
187
188/**
189 * pci_bus_alloc_resource - allocate a resource from a parent bus
190 * @bus: PCI bus
191 * @res: resource to allocate
192 * @size: size of resource to allocate
193 * @align: alignment of resource to allocate
194 * @min: minimum /proc/iomem address to allocate
195 * @type_mask: IORESOURCE_* type flags
196 * @alignf: resource alignment function
197 * @alignf_data: data argument for resource alignment function
198 *
199 * Given the PCI bus a device resides on, the size, minimum address,
200 * alignment and type, try to find an acceptable resource allocation
201 * for a specific device resource.
202 */
203int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
204 resource_size_t size, resource_size_t align,
205 resource_size_t min, unsigned int type_mask,
206 resource_size_t (*alignf)(void *,
207 const struct resource *,
208 resource_size_t,
209 resource_size_t),
210 void *alignf_data)
211{
212#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
213 int rc;
214
215 if (res->flags & IORESOURCE_MEM_64) {
216 rc = pci_bus_alloc_from_region(bus, res, size, align, min,
217 type_mask, alignf, alignf_data,
218 &pci_high);
219 if (rc == 0)
220 return 0;
221
222 return pci_bus_alloc_from_region(bus, res, size, align, min,
223 type_mask, alignf, alignf_data,
224 &pci_64_bit);
225 }
226#endif
227
228 return pci_bus_alloc_from_region(bus, res, size, align, min,
229 type_mask, alignf, alignf_data,
230 &pci_32_bit);
159} 231}
160 232
161void __weak pcibios_resource_survey_bus(struct pci_bus *bus) { } 233void __weak pcibios_resource_survey_bus(struct pci_bus *bus) { }
diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index a68dc613a5be..06ace6248c61 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -9,22 +9,19 @@
9 9
10#include "pci.h" 10#include "pci.h"
11 11
12static struct pci_bus *find_pci_root_bus(struct pci_dev *dev) 12static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
13{ 13{
14 struct pci_bus *bus;
15
16 bus = dev->bus;
17 while (bus->parent) 14 while (bus->parent)
18 bus = bus->parent; 15 bus = bus->parent;
19 16
20 return bus; 17 return bus;
21} 18}
22 19
23static struct pci_host_bridge *find_pci_host_bridge(struct pci_dev *dev) 20static struct pci_host_bridge *find_pci_host_bridge(struct pci_bus *bus)
24{ 21{
25 struct pci_bus *bus = find_pci_root_bus(dev); 22 struct pci_bus *root_bus = find_pci_root_bus(bus);
26 23
27 return to_pci_host_bridge(bus->bridge); 24 return to_pci_host_bridge(root_bus->bridge);
28} 25}
29 26
30void pci_set_host_bridge_release(struct pci_host_bridge *bridge, 27void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
@@ -40,10 +37,10 @@ static bool resource_contains(struct resource *res1, struct resource *res2)
40 return res1->start <= res2->start && res1->end >= res2->end; 37 return res1->start <= res2->start && res1->end >= res2->end;
41} 38}
42 39
43void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 40void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
44 struct resource *res) 41 struct resource *res)
45{ 42{
46 struct pci_host_bridge *bridge = find_pci_host_bridge(dev); 43 struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
47 struct pci_host_bridge_window *window; 44 struct pci_host_bridge_window *window;
48 resource_size_t offset = 0; 45 resource_size_t offset = 0;
49 46
@@ -68,10 +65,10 @@ static bool region_contains(struct pci_bus_region *region1,
68 return region1->start <= region2->start && region1->end >= region2->end; 65 return region1->start <= region2->start && region1->end >= region2->end;
69} 66}
70 67
71void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 68void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
72 struct pci_bus_region *region) 69 struct pci_bus_region *region)
73{ 70{
74 struct pci_host_bridge *bridge = find_pci_host_bridge(dev); 71 struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
75 struct pci_host_bridge_window *window; 72 struct pci_host_bridge_window *window;
76 resource_size_t offset = 0; 73 resource_size_t offset = 0;
77 74
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 12ec56c9a913..23cdfac0bdb3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -269,8 +269,8 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
269 region.end = l + sz; 269 region.end = l + sz;
270 } 270 }
271 271
272 pcibios_bus_to_resource(dev, res, &region); 272 pcibios_bus_to_resource(dev->bus, res, &region);
273 pcibios_resource_to_bus(dev, &inverted_region, res); 273 pcibios_resource_to_bus(dev->bus, &inverted_region, res);
274 274
275 /* 275 /*
276 * If "A" is a BAR value (a bus address), "bus_to_resource(A)" is 276 * If "A" is a BAR value (a bus address), "bus_to_resource(A)" is
@@ -364,7 +364,7 @@ static void pci_read_bridge_io(struct pci_bus *child)
364 res->flags = (io_base_lo & PCI_IO_RANGE_TYPE_MASK) | IORESOURCE_IO; 364 res->flags = (io_base_lo & PCI_IO_RANGE_TYPE_MASK) | IORESOURCE_IO;
365 region.start = base; 365 region.start = base;
366 region.end = limit + io_granularity - 1; 366 region.end = limit + io_granularity - 1;
367 pcibios_bus_to_resource(dev, res, &region); 367 pcibios_bus_to_resource(dev->bus, res, &region);
368 dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res); 368 dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res);
369 } 369 }
370} 370}
@@ -386,7 +386,7 @@ static void pci_read_bridge_mmio(struct pci_bus *child)
386 res->flags = (mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | IORESOURCE_MEM; 386 res->flags = (mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | IORESOURCE_MEM;
387 region.start = base; 387 region.start = base;
388 region.end = limit + 0xfffff; 388 region.end = limit + 0xfffff;
389 pcibios_bus_to_resource(dev, res, &region); 389 pcibios_bus_to_resource(dev->bus, res, &region);
390 dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res); 390 dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res);
391 } 391 }
392} 392}
@@ -436,7 +436,7 @@ static void pci_read_bridge_mmio_pref(struct pci_bus *child)
436 res->flags |= IORESOURCE_MEM_64; 436 res->flags |= IORESOURCE_MEM_64;
437 region.start = base; 437 region.start = base;
438 region.end = limit + 0xfffff; 438 region.end = limit + 0xfffff;
439 pcibios_bus_to_resource(dev, res, &region); 439 pcibios_bus_to_resource(dev->bus, res, &region);
440 dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res); 440 dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res);
441 } 441 }
442} 442}
@@ -1084,24 +1084,24 @@ int pci_setup_device(struct pci_dev *dev)
1084 region.end = 0x1F7; 1084 region.end = 0x1F7;
1085 res = &dev->resource[0]; 1085 res = &dev->resource[0];
1086 res->flags = LEGACY_IO_RESOURCE; 1086 res->flags = LEGACY_IO_RESOURCE;
1087 pcibios_bus_to_resource(dev, res, &region); 1087 pcibios_bus_to_resource(dev->bus, res, &region);
1088 region.start = 0x3F6; 1088 region.start = 0x3F6;
1089 region.end = 0x3F6; 1089 region.end = 0x3F6;
1090 res = &dev->resource[1]; 1090 res = &dev->resource[1];
1091 res->flags = LEGACY_IO_RESOURCE; 1091 res->flags = LEGACY_IO_RESOURCE;
1092 pcibios_bus_to_resource(dev, res, &region); 1092 pcibios_bus_to_resource(dev->bus, res, &region);
1093 } 1093 }
1094 if ((progif & 4) == 0) { 1094 if ((progif & 4) == 0) {
1095 region.start = 0x170; 1095 region.start = 0x170;
1096 region.end = 0x177; 1096 region.end = 0x177;
1097 res = &dev->resource[2]; 1097 res = &dev->resource[2];
1098 res->flags = LEGACY_IO_RESOURCE; 1098 res->flags = LEGACY_IO_RESOURCE;
1099 pcibios_bus_to_resource(dev, res, &region); 1099 pcibios_bus_to_resource(dev->bus, res, &region);
1100 region.start = 0x376; 1100 region.start = 0x376;
1101 region.end = 0x376; 1101 region.end = 0x376;
1102 res = &dev->resource[3]; 1102 res = &dev->resource[3];
1103 res->flags = LEGACY_IO_RESOURCE; 1103 res->flags = LEGACY_IO_RESOURCE;
1104 pcibios_bus_to_resource(dev, res, &region); 1104 pcibios_bus_to_resource(dev->bus, res, &region);
1105 } 1105 }
1106 } 1106 }
1107 break; 1107 break;
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index b3b1b9aa8863..4ad6bf6c107b 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -343,7 +343,7 @@ static void quirk_io_region(struct pci_dev *dev, int port,
343 /* Convert from PCI bus to resource space */ 343 /* Convert from PCI bus to resource space */
344 bus_region.start = region; 344 bus_region.start = region;
345 bus_region.end = region + size - 1; 345 bus_region.end = region + size - 1;
346 pcibios_bus_to_resource(dev, res, &bus_region); 346 pcibios_bus_to_resource(dev->bus, res, &bus_region);
347 347
348 if (!pci_claim_resource(dev, nr)) 348 if (!pci_claim_resource(dev, nr))
349 dev_info(&dev->dev, "quirk: %pR claimed by %s\n", res, name); 349 dev_info(&dev->dev, "quirk: %pR claimed by %s\n", res, name);
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index c5d0a08a8747..5d595724e5f4 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -31,7 +31,7 @@ int pci_enable_rom(struct pci_dev *pdev)
31 if (!res->flags) 31 if (!res->flags)
32 return -1; 32 return -1;
33 33
34 pcibios_resource_to_bus(pdev, &region, res); 34 pcibios_resource_to_bus(pdev->bus, &region, res);
35 pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_addr); 35 pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_addr);
36 rom_addr &= ~PCI_ROM_ADDRESS_MASK; 36 rom_addr &= ~PCI_ROM_ADDRESS_MASK;
37 rom_addr |= region.start | PCI_ROM_ADDRESS_ENABLE; 37 rom_addr |= region.start | PCI_ROM_ADDRESS_ENABLE;
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 2e344a5581ae..138bdd6393be 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -475,7 +475,7 @@ void pci_setup_cardbus(struct pci_bus *bus)
475 &bus->busn_res); 475 &bus->busn_res);
476 476
477 res = bus->resource[0]; 477 res = bus->resource[0];
478 pcibios_resource_to_bus(bridge, &region, res); 478 pcibios_resource_to_bus(bridge->bus, &region, res);
479 if (res->flags & IORESOURCE_IO) { 479 if (res->flags & IORESOURCE_IO) {
480 /* 480 /*
481 * The IO resource is allocated a range twice as large as it 481 * The IO resource is allocated a range twice as large as it
@@ -489,7 +489,7 @@ void pci_setup_cardbus(struct pci_bus *bus)
489 } 489 }
490 490
491 res = bus->resource[1]; 491 res = bus->resource[1];
492 pcibios_resource_to_bus(bridge, &region, res); 492 pcibios_resource_to_bus(bridge->bus, &region, res);
493 if (res->flags & IORESOURCE_IO) { 493 if (res->flags & IORESOURCE_IO) {
494 dev_info(&bridge->dev, " bridge window %pR\n", res); 494 dev_info(&bridge->dev, " bridge window %pR\n", res);
495 pci_write_config_dword(bridge, PCI_CB_IO_BASE_1, 495 pci_write_config_dword(bridge, PCI_CB_IO_BASE_1,
@@ -499,7 +499,7 @@ void pci_setup_cardbus(struct pci_bus *bus)
499 } 499 }
500 500
501 res = bus->resource[2]; 501 res = bus->resource[2];
502 pcibios_resource_to_bus(bridge, &region, res); 502 pcibios_resource_to_bus(bridge->bus, &region, res);
503 if (res->flags & IORESOURCE_MEM) { 503 if (res->flags & IORESOURCE_MEM) {
504 dev_info(&bridge->dev, " bridge window %pR\n", res); 504 dev_info(&bridge->dev, " bridge window %pR\n", res);
505 pci_write_config_dword(bridge, PCI_CB_MEMORY_BASE_0, 505 pci_write_config_dword(bridge, PCI_CB_MEMORY_BASE_0,
@@ -509,7 +509,7 @@ void pci_setup_cardbus(struct pci_bus *bus)
509 } 509 }
510 510
511 res = bus->resource[3]; 511 res = bus->resource[3];
512 pcibios_resource_to_bus(bridge, &region, res); 512 pcibios_resource_to_bus(bridge->bus, &region, res);
513 if (res->flags & IORESOURCE_MEM) { 513 if (res->flags & IORESOURCE_MEM) {
514 dev_info(&bridge->dev, " bridge window %pR\n", res); 514 dev_info(&bridge->dev, " bridge window %pR\n", res);
515 pci_write_config_dword(bridge, PCI_CB_MEMORY_BASE_1, 515 pci_write_config_dword(bridge, PCI_CB_MEMORY_BASE_1,
@@ -547,7 +547,7 @@ static void pci_setup_bridge_io(struct pci_bus *bus)
547 547
548 /* Set up the top and bottom of the PCI I/O segment for this bus. */ 548 /* Set up the top and bottom of the PCI I/O segment for this bus. */
549 res = bus->resource[0]; 549 res = bus->resource[0];
550 pcibios_resource_to_bus(bridge, &region, res); 550 pcibios_resource_to_bus(bridge->bus, &region, res);
551 if (res->flags & IORESOURCE_IO) { 551 if (res->flags & IORESOURCE_IO) {
552 pci_read_config_word(bridge, PCI_IO_BASE, &l); 552 pci_read_config_word(bridge, PCI_IO_BASE, &l);
553 io_base_lo = (region.start >> 8) & io_mask; 553 io_base_lo = (region.start >> 8) & io_mask;
@@ -578,7 +578,7 @@ static void pci_setup_bridge_mmio(struct pci_bus *bus)
578 578
579 /* Set up the top and bottom of the PCI Memory segment for this bus. */ 579 /* Set up the top and bottom of the PCI Memory segment for this bus. */
580 res = bus->resource[1]; 580 res = bus->resource[1];
581 pcibios_resource_to_bus(bridge, &region, res); 581 pcibios_resource_to_bus(bridge->bus, &region, res);
582 if (res->flags & IORESOURCE_MEM) { 582 if (res->flags & IORESOURCE_MEM) {
583 l = (region.start >> 16) & 0xfff0; 583 l = (region.start >> 16) & 0xfff0;
584 l |= region.end & 0xfff00000; 584 l |= region.end & 0xfff00000;
@@ -604,7 +604,7 @@ static void pci_setup_bridge_mmio_pref(struct pci_bus *bus)
604 /* Set up PREF base/limit. */ 604 /* Set up PREF base/limit. */
605 bu = lu = 0; 605 bu = lu = 0;
606 res = bus->resource[2]; 606 res = bus->resource[2];
607 pcibios_resource_to_bus(bridge, &region, res); 607 pcibios_resource_to_bus(bridge->bus, &region, res);
608 if (res->flags & IORESOURCE_PREFETCH) { 608 if (res->flags & IORESOURCE_PREFETCH) {
609 l = (region.start >> 16) & 0xfff0; 609 l = (region.start >> 16) & 0xfff0;
610 l |= region.end & 0xfff00000; 610 l |= region.end & 0xfff00000;
@@ -1424,7 +1424,7 @@ static int iov_resources_unassigned(struct pci_dev *dev, void *data)
1424 if (!r->flags) 1424 if (!r->flags)
1425 continue; 1425 continue;
1426 1426
1427 pcibios_resource_to_bus(dev, &region, r); 1427 pcibios_resource_to_bus(dev->bus, &region, r);
1428 if (!region.start) { 1428 if (!region.start) {
1429 *unassigned = true; 1429 *unassigned = true;
1430 return 1; /* return early from pci_walk_bus() */ 1430 return 1; /* return early from pci_walk_bus() */
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 83c4d3bc47ab..5c060b152ce6 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -52,7 +52,7 @@ void pci_update_resource(struct pci_dev *dev, int resno)
52 if (res->flags & IORESOURCE_PCI_FIXED) 52 if (res->flags & IORESOURCE_PCI_FIXED)
53 return; 53 return;
54 54
55 pcibios_resource_to_bus(dev, &region, res); 55 pcibios_resource_to_bus(dev->bus, &region, res);
56 56
57 new = region.start | (res->flags & PCI_REGION_FLAG_MASK); 57 new = region.start | (res->flags & PCI_REGION_FLAG_MASK);
58 if (res->flags & IORESOURCE_IO) 58 if (res->flags & IORESOURCE_IO)
diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c
index 519c4d6003a6..7d47456429a1 100644
--- a/drivers/pcmcia/i82092.c
+++ b/drivers/pcmcia/i82092.c
@@ -608,7 +608,7 @@ static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_
608 608
609 enter("i82092aa_set_mem_map"); 609 enter("i82092aa_set_mem_map");
610 610
611 pcibios_resource_to_bus(sock_info->dev, &region, mem->res); 611 pcibios_resource_to_bus(sock_info->dev->bus, &region, mem->res);
612 612
613 map = mem->map; 613 map = mem->map;
614 if (map > 4) { 614 if (map > 4) {
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index dc18a3a5e010..8485761e76af 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -445,7 +445,7 @@ static int yenta_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *
445 unsigned int start, stop, card_start; 445 unsigned int start, stop, card_start;
446 unsigned short word; 446 unsigned short word;
447 447
448 pcibios_resource_to_bus(socket->dev, &region, mem->res); 448 pcibios_resource_to_bus(socket->dev->bus, &region, mem->res);
449 449
450 map = mem->map; 450 map = mem->map;
451 start = region.start; 451 start = region.start;
@@ -709,7 +709,7 @@ static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type
709 region.start = config_readl(socket, addr_start) & mask; 709 region.start = config_readl(socket, addr_start) & mask;
710 region.end = config_readl(socket, addr_end) | ~mask; 710 region.end = config_readl(socket, addr_end) | ~mask;
711 if (region.start && region.end > region.start && !override_bios) { 711 if (region.start && region.end > region.start && !override_bios) {
712 pcibios_bus_to_resource(dev, res, &region); 712 pcibios_bus_to_resource(dev->bus, res, &region);
713 if (pci_claim_resource(dev, PCI_BRIDGE_RESOURCES + nr) == 0) 713 if (pci_claim_resource(dev, PCI_BRIDGE_RESOURCES + nr) == 0)
714 return 0; 714 return 0;
715 dev_printk(KERN_INFO, &dev->dev, 715 dev_printk(KERN_INFO, &dev->dev,
@@ -1033,7 +1033,7 @@ static void yenta_config_init(struct yenta_socket *socket)
1033 struct pci_dev *dev = socket->dev; 1033 struct pci_dev *dev = socket->dev;
1034 struct pci_bus_region region; 1034 struct pci_bus_region region;
1035 1035
1036 pcibios_resource_to_bus(socket->dev, &region, &dev->resource[0]); 1036 pcibios_resource_to_bus(socket->dev->bus, &region, &dev->resource[0]);
1037 1037
1038 config_writel(socket, CB_LEGACY_MODE_BASE, 0); 1038 config_writel(socket, CB_LEGACY_MODE_BASE, 0);
1039 config_writel(socket, PCI_BASE_ADDRESS_0, region.start); 1039 config_writel(socket, PCI_BASE_ADDRESS_0, region.start);
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index bac55f7f69f9..6d3ee1ab6362 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -1531,7 +1531,7 @@ static int sym_iomap_device(struct sym_device *device)
1531 struct pci_bus_region bus_addr; 1531 struct pci_bus_region bus_addr;
1532 int i = 2; 1532 int i = 2;
1533 1533
1534 pcibios_resource_to_bus(pdev, &bus_addr, &pdev->resource[1]); 1534 pcibios_resource_to_bus(pdev->bus, &bus_addr, &pdev->resource[1]);
1535 device->mmio_base = bus_addr.start; 1535 device->mmio_base = bus_addr.start;
1536 1536
1537 if (device->chip.features & FE_RAM) { 1537 if (device->chip.features & FE_RAM) {
@@ -1541,7 +1541,8 @@ static int sym_iomap_device(struct sym_device *device)
1541 */ 1541 */
1542 if (!pdev->resource[i].flags) 1542 if (!pdev->resource[i].flags)
1543 i++; 1543 i++;
1544 pcibios_resource_to_bus(pdev, &bus_addr, &pdev->resource[i]); 1544 pcibios_resource_to_bus(pdev->bus, &bus_addr,
1545 &pdev->resource[i]);
1545 device->ram_base = bus_addr.start; 1546 device->ram_base = bus_addr.start;
1546 } 1547 }
1547 1548
diff --git a/drivers/video/arkfb.c b/drivers/video/arkfb.c
index a6b29bd4a12a..adc4ea2cc5a0 100644
--- a/drivers/video/arkfb.c
+++ b/drivers/video/arkfb.c
@@ -1014,7 +1014,7 @@ static int ark_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
1014 1014
1015 vga_res.flags = IORESOURCE_IO; 1015 vga_res.flags = IORESOURCE_IO;
1016 1016
1017 pcibios_bus_to_resource(dev, &vga_res, &bus_reg); 1017 pcibios_bus_to_resource(dev->bus, &vga_res, &bus_reg);
1018 1018
1019 par->state.vgabase = (void __iomem *) vga_res.start; 1019 par->state.vgabase = (void __iomem *) vga_res.start;
1020 1020
diff --git a/drivers/video/s3fb.c b/drivers/video/s3fb.c
index 968b2997175a..9a3f8f1c6aab 100644
--- a/drivers/video/s3fb.c
+++ b/drivers/video/s3fb.c
@@ -1180,7 +1180,7 @@ static int s3_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
1180 1180
1181 vga_res.flags = IORESOURCE_IO; 1181 vga_res.flags = IORESOURCE_IO;
1182 1182
1183 pcibios_bus_to_resource(dev, &vga_res, &bus_reg); 1183 pcibios_bus_to_resource(dev->bus, &vga_res, &bus_reg);
1184 1184
1185 par->state.vgabase = (void __iomem *) vga_res.start; 1185 par->state.vgabase = (void __iomem *) vga_res.start;
1186 1186
diff --git a/drivers/video/vt8623fb.c b/drivers/video/vt8623fb.c
index 8bc6e0958a09..5c7cbc6c6236 100644
--- a/drivers/video/vt8623fb.c
+++ b/drivers/video/vt8623fb.c
@@ -729,7 +729,7 @@ static int vt8623_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
729 729
730 vga_res.flags = IORESOURCE_IO; 730 vga_res.flags = IORESOURCE_IO;
731 731
732 pcibios_bus_to_resource(dev, &vga_res, &bus_reg); 732 pcibios_bus_to_resource(dev->bus, &vga_res, &bus_reg);
733 733
734 par->state.vgabase = (void __iomem *) vga_res.start; 734 par->state.vgabase = (void __iomem *) vga_res.start;
735 735
diff --git a/include/linux/pci.h b/include/linux/pci.h
index b89069839020..f7d1dcc002fa 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -552,8 +552,8 @@ int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn,
552 int reg, int len, u32 val); 552 int reg, int len, u32 val);
553 553
554struct pci_bus_region { 554struct pci_bus_region {
555 resource_size_t start; 555 dma_addr_t start;
556 resource_size_t end; 556 dma_addr_t end;
557}; 557};
558 558
559struct pci_dynids { 559struct pci_dynids {
@@ -737,9 +737,9 @@ void pci_fixup_cardbus(struct pci_bus *);
737 737
738/* Generic PCI functions used internally */ 738/* Generic PCI functions used internally */
739 739
740void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 740void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
741 struct resource *res); 741 struct resource *res);
742void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 742void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
743 struct pci_bus_region *region); 743 struct pci_bus_region *region);
744void pcibios_scan_specific_bus(int busn); 744void pcibios_scan_specific_bus(int busn);
745struct pci_bus *pci_find_bus(int domain, int busnr); 745struct pci_bus *pci_find_bus(int domain, int busnr);
@@ -1089,6 +1089,14 @@ int __must_check pci_bus_alloc_resource(struct pci_bus *bus,
1089 resource_size_t), 1089 resource_size_t),
1090 void *alignf_data); 1090 void *alignf_data);
1091 1091
1092static inline dma_addr_t pci_bus_address(struct pci_dev *pdev, int bar)
1093{
1094 struct pci_bus_region region;
1095
1096 pcibios_resource_to_bus(pdev->bus, &region, &pdev->resource[bar]);
1097 return region.start;
1098}
1099
1092/* Proper probing supporting hot-pluggable devices */ 1100/* Proper probing supporting hot-pluggable devices */
1093int __must_check __pci_register_driver(struct pci_driver *, struct module *, 1101int __must_check __pci_register_driver(struct pci_driver *, struct module *,
1094 const char *mod_name); 1102 const char *mod_name);
@@ -1510,10 +1518,6 @@ static inline struct pci_dev *pci_dev_get(struct pci_dev *dev)
1510 1518
1511#include <asm/pci.h> 1519#include <asm/pci.h>
1512 1520
1513#ifndef PCIBIOS_MAX_MEM_32
1514#define PCIBIOS_MAX_MEM_32 (-1)
1515#endif
1516
1517/* these helpers provide future and backwards compatibility 1521/* these helpers provide future and backwards compatibility
1518 * for accessing popular PCI BAR info */ 1522 * for accessing popular PCI BAR info */
1519#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start) 1523#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)