aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <Keir.Fraser@cl.cam.ac.uk>2005-03-30 16:17:04 -0500
committerDave Jones <davej@redhat.com>2005-06-07 15:35:43 -0400
commit07eee78ea8ba2d0b7b20551c35a3e7dd158d50bb (patch)
treea11d2e705253faaa9779cfd83bb8ca9de311b195
parente29b545cb153f230fbd8ff4c19bc98ab950f9f5c (diff)
[PATCH] AGP fix for Xen VMM
When Linux is running on the Xen virtual machine monitor, physical addresses are virtualised and cannot be directly referenced by the AGP GART. This patch fixes the GART driver for Xen by adding a layer of abstraction between physical addresses and 'GART addresses'. Architecture-specific functions are also defined for allocating and freeing the GATT. Xen requires this to ensure that table really is contiguous from the point of view of the GART. These extra interface functions are defined as 'no-ops' for all existing architectures that use the GART driver. Signed-off-by: Keir Fraser <keir@xensource.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Dave Jones <davej@redhat.com>
-rw-r--r--drivers/char/agp/agp.h2
-rw-r--r--drivers/char/agp/ali-agp.c4
-rw-r--r--drivers/char/agp/amd-k7-agp.c6
-rw-r--r--drivers/char/agp/amd64-agp.c4
-rw-r--r--drivers/char/agp/ati-agp.c6
-rw-r--r--drivers/char/agp/backend.c6
-rw-r--r--drivers/char/agp/efficeon-agp.c2
-rw-r--r--drivers/char/agp/generic.c17
-rw-r--r--drivers/char/agp/hp-agp.c4
-rw-r--r--drivers/char/agp/i460-agp.c4
-rw-r--r--drivers/char/agp/intel-agp.c6
-rw-r--r--drivers/char/agp/sworks-agp.c8
-rw-r--r--drivers/char/agp/uninorth-agp.c2
-rw-r--r--include/asm-alpha/agp.h10
-rw-r--r--include/asm-i386/agp.h10
-rw-r--r--include/asm-ia64/agp.h10
-rw-r--r--include/asm-ppc/agp.h10
-rw-r--r--include/asm-ppc64/agp.h10
-rw-r--r--include/asm-sparc64/agp.h10
-rw-r--r--include/asm-x86_64/agp.h10
20 files changed, 106 insertions, 35 deletions
diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h
index ad9c11391d81..c1fe013c64f3 100644
--- a/drivers/char/agp/agp.h
+++ b/drivers/char/agp/agp.h
@@ -278,6 +278,8 @@ void agp3_generic_cleanup(void);
278#define AGP_GENERIC_SIZES_ENTRIES 11 278#define AGP_GENERIC_SIZES_ENTRIES 11
279extern struct aper_size_info_16 agp3_generic_sizes[]; 279extern struct aper_size_info_16 agp3_generic_sizes[];
280 280
281#define virt_to_gart(x) (phys_to_gart(virt_to_phys(x)))
282#define gart_to_virt(x) (phys_to_virt(gart_to_phys(x)))
281 283
282extern int agp_off; 284extern int agp_off;
283extern int agp_try_unsupported_boot; 285extern int agp_try_unsupported_boot;
diff --git a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c
index 0212febda654..9c9c9c2247ce 100644
--- a/drivers/char/agp/ali-agp.c
+++ b/drivers/char/agp/ali-agp.c
@@ -150,7 +150,7 @@ static void *m1541_alloc_page(struct agp_bridge_data *bridge)
150 pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp); 150 pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp);
151 pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, 151 pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL,
152 (((temp & ALI_CACHE_FLUSH_ADDR_MASK) | 152 (((temp & ALI_CACHE_FLUSH_ADDR_MASK) |
153 virt_to_phys(addr)) | ALI_CACHE_FLUSH_EN )); 153 virt_to_gart(addr)) | ALI_CACHE_FLUSH_EN ));
154 return addr; 154 return addr;
155} 155}
156 156
@@ -174,7 +174,7 @@ static void m1541_destroy_page(void * addr)
174 pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp); 174 pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp);
175 pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, 175 pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL,
176 (((temp & ALI_CACHE_FLUSH_ADDR_MASK) | 176 (((temp & ALI_CACHE_FLUSH_ADDR_MASK) |
177 virt_to_phys(addr)) | ALI_CACHE_FLUSH_EN)); 177 virt_to_gart(addr)) | ALI_CACHE_FLUSH_EN));
178 agp_generic_destroy_page(addr); 178 agp_generic_destroy_page(addr);
179} 179}
180 180
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c
index e62a3c2c44a9..3a41672e4d66 100644
--- a/drivers/char/agp/amd-k7-agp.c
+++ b/drivers/char/agp/amd-k7-agp.c
@@ -43,7 +43,7 @@ static int amd_create_page_map(struct amd_page_map *page_map)
43 43
44 SetPageReserved(virt_to_page(page_map->real)); 44 SetPageReserved(virt_to_page(page_map->real));
45 global_cache_flush(); 45 global_cache_flush();
46 page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real), 46 page_map->remapped = ioremap_nocache(virt_to_gart(page_map->real),
47 PAGE_SIZE); 47 PAGE_SIZE);
48 if (page_map->remapped == NULL) { 48 if (page_map->remapped == NULL) {
49 ClearPageReserved(virt_to_page(page_map->real)); 49 ClearPageReserved(virt_to_page(page_map->real));
@@ -154,7 +154,7 @@ static int amd_create_gatt_table(struct agp_bridge_data *bridge)
154 154
155 agp_bridge->gatt_table_real = (u32 *)page_dir.real; 155 agp_bridge->gatt_table_real = (u32 *)page_dir.real;
156 agp_bridge->gatt_table = (u32 __iomem *)page_dir.remapped; 156 agp_bridge->gatt_table = (u32 __iomem *)page_dir.remapped;
157 agp_bridge->gatt_bus_addr = virt_to_phys(page_dir.real); 157 agp_bridge->gatt_bus_addr = virt_to_gart(page_dir.real);
158 158
159 /* Get the address for the gart region. 159 /* Get the address for the gart region.
160 * This is a bus address even on the alpha, b/c its 160 * This is a bus address even on the alpha, b/c its
@@ -167,7 +167,7 @@ static int amd_create_gatt_table(struct agp_bridge_data *bridge)
167 167
168 /* Calculate the agp offset */ 168 /* Calculate the agp offset */
169 for (i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) { 169 for (i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) {
170 writel(virt_to_phys(amd_irongate_private.gatt_pages[i]->real) | 1, 170 writel(virt_to_gart(amd_irongate_private.gatt_pages[i]->real) | 1,
171 page_dir.remapped+GET_PAGE_DIR_OFF(addr)); 171 page_dir.remapped+GET_PAGE_DIR_OFF(addr));
172 readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI Posting. */ 172 readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI Posting. */
173 } 173 }
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 399c042f68f0..1407945a5892 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -219,7 +219,7 @@ static struct aper_size_info_32 amd_8151_sizes[7] =
219 219
220static int amd_8151_configure(void) 220static int amd_8151_configure(void)
221{ 221{
222 unsigned long gatt_bus = virt_to_phys(agp_bridge->gatt_table_real); 222 unsigned long gatt_bus = virt_to_gart(agp_bridge->gatt_table_real);
223 223
224 /* Configure AGP regs in each x86-64 host bridge. */ 224 /* Configure AGP regs in each x86-64 host bridge. */
225 for_each_nb() { 225 for_each_nb() {
@@ -591,7 +591,7 @@ static void __devexit agp_amd64_remove(struct pci_dev *pdev)
591{ 591{
592 struct agp_bridge_data *bridge = pci_get_drvdata(pdev); 592 struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
593 593
594 release_mem_region(virt_to_phys(bridge->gatt_table_real), 594 release_mem_region(virt_to_gart(bridge->gatt_table_real),
595 amd64_aperture_sizes[bridge->aperture_size_idx].size); 595 amd64_aperture_sizes[bridge->aperture_size_idx].size);
596 agp_remove_bridge(bridge); 596 agp_remove_bridge(bridge);
597 agp_put_bridge(bridge); 597 agp_put_bridge(bridge);
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
index a65f8827c283..e572ced9100a 100644
--- a/drivers/char/agp/ati-agp.c
+++ b/drivers/char/agp/ati-agp.c
@@ -61,7 +61,7 @@ static int ati_create_page_map(ati_page_map *page_map)
61 61
62 SetPageReserved(virt_to_page(page_map->real)); 62 SetPageReserved(virt_to_page(page_map->real));
63 err = map_page_into_agp(virt_to_page(page_map->real)); 63 err = map_page_into_agp(virt_to_page(page_map->real));
64 page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real), 64 page_map->remapped = ioremap_nocache(virt_to_gart(page_map->real),
65 PAGE_SIZE); 65 PAGE_SIZE);
66 if (page_map->remapped == NULL || err) { 66 if (page_map->remapped == NULL || err) {
67 ClearPageReserved(virt_to_page(page_map->real)); 67 ClearPageReserved(virt_to_page(page_map->real));
@@ -343,7 +343,7 @@ static int ati_create_gatt_table(struct agp_bridge_data *bridge)
343 343
344 agp_bridge->gatt_table_real = (u32 *)page_dir.real; 344 agp_bridge->gatt_table_real = (u32 *)page_dir.real;
345 agp_bridge->gatt_table = (u32 __iomem *) page_dir.remapped; 345 agp_bridge->gatt_table = (u32 __iomem *) page_dir.remapped;
346 agp_bridge->gatt_bus_addr = virt_to_bus(page_dir.real); 346 agp_bridge->gatt_bus_addr = virt_to_gart(page_dir.real);
347 347
348 /* Write out the size register */ 348 /* Write out the size register */
349 current_size = A_SIZE_LVL2(agp_bridge->current_size); 349 current_size = A_SIZE_LVL2(agp_bridge->current_size);
@@ -373,7 +373,7 @@ static int ati_create_gatt_table(struct agp_bridge_data *bridge)
373 373
374 /* Calculate the agp offset */ 374 /* Calculate the agp offset */
375 for(i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) { 375 for(i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) {
376 writel(virt_to_bus(ati_generic_private.gatt_pages[i]->real) | 1, 376 writel(virt_to_gart(ati_generic_private.gatt_pages[i]->real) | 1,
377 page_dir.remapped+GET_PAGE_DIR_OFF(addr)); 377 page_dir.remapped+GET_PAGE_DIR_OFF(addr));
378 readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI Posting. */ 378 readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI Posting. */
379 } 379 }
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
index 2f3dfb63bdc6..4d4e602fdc7e 100644
--- a/drivers/char/agp/backend.c
+++ b/drivers/char/agp/backend.c
@@ -148,7 +148,7 @@ static int agp_backend_initialize(struct agp_bridge_data *bridge)
148 return -ENOMEM; 148 return -ENOMEM;
149 } 149 }
150 150
151 bridge->scratch_page_real = virt_to_phys(addr); 151 bridge->scratch_page_real = virt_to_gart(addr);
152 bridge->scratch_page = 152 bridge->scratch_page =
153 bridge->driver->mask_memory(bridge, bridge->scratch_page_real, 0); 153 bridge->driver->mask_memory(bridge, bridge->scratch_page_real, 0);
154 } 154 }
@@ -189,7 +189,7 @@ static int agp_backend_initialize(struct agp_bridge_data *bridge)
189err_out: 189err_out:
190 if (bridge->driver->needs_scratch_page) 190 if (bridge->driver->needs_scratch_page)
191 bridge->driver->agp_destroy_page( 191 bridge->driver->agp_destroy_page(
192 phys_to_virt(bridge->scratch_page_real)); 192 gart_to_virt(bridge->scratch_page_real));
193 if (got_gatt) 193 if (got_gatt)
194 bridge->driver->free_gatt_table(bridge); 194 bridge->driver->free_gatt_table(bridge);
195 if (got_keylist) { 195 if (got_keylist) {
@@ -214,7 +214,7 @@ static void agp_backend_cleanup(struct agp_bridge_data *bridge)
214 if (bridge->driver->agp_destroy_page && 214 if (bridge->driver->agp_destroy_page &&
215 bridge->driver->needs_scratch_page) 215 bridge->driver->needs_scratch_page)
216 bridge->driver->agp_destroy_page( 216 bridge->driver->agp_destroy_page(
217 phys_to_virt(bridge->scratch_page_real)); 217 gart_to_virt(bridge->scratch_page_real));
218} 218}
219 219
220/* When we remove the global variable agp_bridge from all drivers 220/* When we remove the global variable agp_bridge from all drivers
diff --git a/drivers/char/agp/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c
index 1383c3165ea1..ac19fdcd21c1 100644
--- a/drivers/char/agp/efficeon-agp.c
+++ b/drivers/char/agp/efficeon-agp.c
@@ -219,7 +219,7 @@ static int efficeon_create_gatt_table(struct agp_bridge_data *bridge)
219 219
220 efficeon_private.l1_table[index] = page; 220 efficeon_private.l1_table[index] = page;
221 221
222 value = __pa(page) | pati | present | index; 222 value = virt_to_gart(page) | pati | present | index;
223 223
224 pci_write_config_dword(agp_bridge->dev, 224 pci_write_config_dword(agp_bridge->dev,
225 EFFICEON_ATTPAGE, value); 225 EFFICEON_ATTPAGE, value);
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index c321a924e38a..d62505b5d25a 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -153,7 +153,7 @@ void agp_free_memory(struct agp_memory *curr)
153 } 153 }
154 if (curr->page_count != 0) { 154 if (curr->page_count != 0) {
155 for (i = 0; i < curr->page_count; i++) { 155 for (i = 0; i < curr->page_count; i++) {
156 curr->bridge->driver->agp_destroy_page(phys_to_virt(curr->memory[i])); 156 curr->bridge->driver->agp_destroy_page(gart_to_virt(curr->memory[i]));
157 } 157 }
158 } 158 }
159 agp_free_key(curr->key); 159 agp_free_key(curr->key);
@@ -209,7 +209,7 @@ struct agp_memory *agp_allocate_memory(struct agp_bridge_data *bridge,
209 agp_free_memory(new); 209 agp_free_memory(new);
210 return NULL; 210 return NULL;
211 } 211 }
212 new->memory[i] = virt_to_phys(addr); 212 new->memory[i] = virt_to_gart(addr);
213 new->page_count++; 213 new->page_count++;
214 } 214 }
215 new->bridge = bridge; 215 new->bridge = bridge;
@@ -806,8 +806,7 @@ int agp_generic_create_gatt_table(struct agp_bridge_data *bridge)
806 break; 806 break;
807 } 807 }
808 808
809 table = (char *) __get_free_pages(GFP_KERNEL, 809 table = alloc_gatt_pages(page_order);
810 page_order);
811 810
812 if (table == NULL) { 811 if (table == NULL) {
813 i++; 812 i++;
@@ -838,7 +837,7 @@ int agp_generic_create_gatt_table(struct agp_bridge_data *bridge)
838 size = ((struct aper_size_info_fixed *) temp)->size; 837 size = ((struct aper_size_info_fixed *) temp)->size;
839 page_order = ((struct aper_size_info_fixed *) temp)->page_order; 838 page_order = ((struct aper_size_info_fixed *) temp)->page_order;
840 num_entries = ((struct aper_size_info_fixed *) temp)->num_entries; 839 num_entries = ((struct aper_size_info_fixed *) temp)->num_entries;
841 table = (char *) __get_free_pages(GFP_KERNEL, page_order); 840 table = alloc_gatt_pages(page_order);
842 } 841 }
843 842
844 if (table == NULL) 843 if (table == NULL)
@@ -853,7 +852,7 @@ int agp_generic_create_gatt_table(struct agp_bridge_data *bridge)
853 agp_gatt_table = (void *)table; 852 agp_gatt_table = (void *)table;
854 853
855 bridge->driver->cache_flush(); 854 bridge->driver->cache_flush();
856 bridge->gatt_table = ioremap_nocache(virt_to_phys(table), 855 bridge->gatt_table = ioremap_nocache(virt_to_gart(table),
857 (PAGE_SIZE * (1 << page_order))); 856 (PAGE_SIZE * (1 << page_order)));
858 bridge->driver->cache_flush(); 857 bridge->driver->cache_flush();
859 858
@@ -861,11 +860,11 @@ int agp_generic_create_gatt_table(struct agp_bridge_data *bridge)
861 for (page = virt_to_page(table); page <= virt_to_page(table_end); page++) 860 for (page = virt_to_page(table); page <= virt_to_page(table_end); page++)
862 ClearPageReserved(page); 861 ClearPageReserved(page);
863 862
864 free_pages((unsigned long) table, page_order); 863 free_gatt_pages(table, page_order);
865 864
866 return -ENOMEM; 865 return -ENOMEM;
867 } 866 }
868 bridge->gatt_bus_addr = virt_to_phys(bridge->gatt_table_real); 867 bridge->gatt_bus_addr = virt_to_gart(bridge->gatt_table_real);
869 868
870 /* AK: bogus, should encode addresses > 4GB */ 869 /* AK: bogus, should encode addresses > 4GB */
871 for (i = 0; i < num_entries; i++) { 870 for (i = 0; i < num_entries; i++) {
@@ -919,7 +918,7 @@ int agp_generic_free_gatt_table(struct agp_bridge_data *bridge)
919 for (page = virt_to_page(table); page <= virt_to_page(table_end); page++) 918 for (page = virt_to_page(table); page <= virt_to_page(table_end); page++)
920 ClearPageReserved(page); 919 ClearPageReserved(page);
921 920
922 free_pages((unsigned long) bridge->gatt_table_real, page_order); 921 free_gatt_pages(bridge->gatt_table_real, page_order);
923 922
924 agp_gatt_table = NULL; 923 agp_gatt_table = NULL;
925 bridge->gatt_table = NULL; 924 bridge->gatt_table = NULL;
diff --git a/drivers/char/agp/hp-agp.c b/drivers/char/agp/hp-agp.c
index 6052bfa04c72..99762b6c19ae 100644
--- a/drivers/char/agp/hp-agp.c
+++ b/drivers/char/agp/hp-agp.c
@@ -110,7 +110,7 @@ static int __init hp_zx1_ioc_shared(void)
110 hp->gart_size = HP_ZX1_GART_SIZE; 110 hp->gart_size = HP_ZX1_GART_SIZE;
111 hp->gatt_entries = hp->gart_size / hp->io_page_size; 111 hp->gatt_entries = hp->gart_size / hp->io_page_size;
112 112
113 hp->io_pdir = phys_to_virt(readq(hp->ioc_regs+HP_ZX1_PDIR_BASE)); 113 hp->io_pdir = gart_to_virt(readq(hp->ioc_regs+HP_ZX1_PDIR_BASE));
114 hp->gatt = &hp->io_pdir[HP_ZX1_IOVA_TO_PDIR(hp->gart_base)]; 114 hp->gatt = &hp->io_pdir[HP_ZX1_IOVA_TO_PDIR(hp->gart_base)];
115 115
116 if (hp->gatt[0] != HP_ZX1_SBA_IOMMU_COOKIE) { 116 if (hp->gatt[0] != HP_ZX1_SBA_IOMMU_COOKIE) {
@@ -248,7 +248,7 @@ hp_zx1_configure (void)
248 agp_bridge->mode = readl(hp->lba_regs+hp->lba_cap_offset+PCI_AGP_STATUS); 248 agp_bridge->mode = readl(hp->lba_regs+hp->lba_cap_offset+PCI_AGP_STATUS);
249 249
250 if (hp->io_pdir_owner) { 250 if (hp->io_pdir_owner) {
251 writel(virt_to_phys(hp->io_pdir), hp->ioc_regs+HP_ZX1_PDIR_BASE); 251 writel(virt_to_gart(hp->io_pdir), hp->ioc_regs+HP_ZX1_PDIR_BASE);
252 readl(hp->ioc_regs+HP_ZX1_PDIR_BASE); 252 readl(hp->ioc_regs+HP_ZX1_PDIR_BASE);
253 writel(hp->io_tlb_ps, hp->ioc_regs+HP_ZX1_TCNFG); 253 writel(hp->io_tlb_ps, hp->ioc_regs+HP_ZX1_TCNFG);
254 readl(hp->ioc_regs+HP_ZX1_TCNFG); 254 readl(hp->ioc_regs+HP_ZX1_TCNFG);
diff --git a/drivers/char/agp/i460-agp.c b/drivers/char/agp/i460-agp.c
index adbea896c0d2..94943298c03e 100644
--- a/drivers/char/agp/i460-agp.c
+++ b/drivers/char/agp/i460-agp.c
@@ -372,7 +372,7 @@ static int i460_alloc_large_page (struct lp_desc *lp)
372 } 372 }
373 memset(lp->alloced_map, 0, map_size); 373 memset(lp->alloced_map, 0, map_size);
374 374
375 lp->paddr = virt_to_phys(lpage); 375 lp->paddr = virt_to_gart(lpage);
376 lp->refcount = 0; 376 lp->refcount = 0;
377 atomic_add(I460_KPAGES_PER_IOPAGE, &agp_bridge->current_memory_agp); 377 atomic_add(I460_KPAGES_PER_IOPAGE, &agp_bridge->current_memory_agp);
378 return 0; 378 return 0;
@@ -383,7 +383,7 @@ static void i460_free_large_page (struct lp_desc *lp)
383 kfree(lp->alloced_map); 383 kfree(lp->alloced_map);
384 lp->alloced_map = NULL; 384 lp->alloced_map = NULL;
385 385
386 free_pages((unsigned long) phys_to_virt(lp->paddr), I460_IO_PAGE_SHIFT - PAGE_SHIFT); 386 free_pages((unsigned long) gart_to_virt(lp->paddr), I460_IO_PAGE_SHIFT - PAGE_SHIFT);
387 atomic_sub(I460_KPAGES_PER_IOPAGE, &agp_bridge->current_memory_agp); 387 atomic_sub(I460_KPAGES_PER_IOPAGE, &agp_bridge->current_memory_agp);
388} 388}
389 389
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 6a5047e0d333..51266d6b4d78 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -286,7 +286,7 @@ static struct agp_memory *alloc_agpphysmem_i8xx(size_t pg_count, int type)
286 if (new == NULL) 286 if (new == NULL)
287 return NULL; 287 return NULL;
288 288
289 new->memory[0] = virt_to_phys(addr); 289 new->memory[0] = virt_to_gart(addr);
290 if (pg_count == 4) { 290 if (pg_count == 4) {
291 /* kludge to get 4 physical pages for ARGB cursor */ 291 /* kludge to get 4 physical pages for ARGB cursor */
292 new->memory[1] = new->memory[0] + PAGE_SIZE; 292 new->memory[1] = new->memory[0] + PAGE_SIZE;
@@ -329,10 +329,10 @@ static void intel_i810_free_by_type(struct agp_memory *curr)
329 agp_free_key(curr->key); 329 agp_free_key(curr->key);
330 if(curr->type == AGP_PHYS_MEMORY) { 330 if(curr->type == AGP_PHYS_MEMORY) {
331 if (curr->page_count == 4) 331 if (curr->page_count == 4)
332 i8xx_destroy_pages(phys_to_virt(curr->memory[0])); 332 i8xx_destroy_pages(gart_to_virt(curr->memory[0]));
333 else 333 else
334 agp_bridge->driver->agp_destroy_page( 334 agp_bridge->driver->agp_destroy_page(
335 phys_to_virt(curr->memory[0])); 335 gart_to_virt(curr->memory[0]));
336 vfree(curr->memory); 336 vfree(curr->memory);
337 } 337 }
338 kfree(curr); 338 kfree(curr);
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c
index 10c23302dd84..a9fb12c20eb7 100644
--- a/drivers/char/agp/sworks-agp.c
+++ b/drivers/char/agp/sworks-agp.c
@@ -51,7 +51,7 @@ static int serverworks_create_page_map(struct serverworks_page_map *page_map)
51 } 51 }
52 SetPageReserved(virt_to_page(page_map->real)); 52 SetPageReserved(virt_to_page(page_map->real));
53 global_cache_flush(); 53 global_cache_flush();
54 page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real), 54 page_map->remapped = ioremap_nocache(virt_to_gart(page_map->real),
55 PAGE_SIZE); 55 PAGE_SIZE);
56 if (page_map->remapped == NULL) { 56 if (page_map->remapped == NULL) {
57 ClearPageReserved(virt_to_page(page_map->real)); 57 ClearPageReserved(virt_to_page(page_map->real));
@@ -162,7 +162,7 @@ static int serverworks_create_gatt_table(struct agp_bridge_data *bridge)
162 /* Create a fake scratch directory */ 162 /* Create a fake scratch directory */
163 for(i = 0; i < 1024; i++) { 163 for(i = 0; i < 1024; i++) {
164 writel(agp_bridge->scratch_page, serverworks_private.scratch_dir.remapped+i); 164 writel(agp_bridge->scratch_page, serverworks_private.scratch_dir.remapped+i);
165 writel(virt_to_phys(serverworks_private.scratch_dir.real) | 1, page_dir.remapped+i); 165 writel(virt_to_gart(serverworks_private.scratch_dir.real) | 1, page_dir.remapped+i);
166 } 166 }
167 167
168 retval = serverworks_create_gatt_pages(value->num_entries / 1024); 168 retval = serverworks_create_gatt_pages(value->num_entries / 1024);
@@ -174,7 +174,7 @@ static int serverworks_create_gatt_table(struct agp_bridge_data *bridge)
174 174
175 agp_bridge->gatt_table_real = (u32 *)page_dir.real; 175 agp_bridge->gatt_table_real = (u32 *)page_dir.real;
176 agp_bridge->gatt_table = (u32 __iomem *)page_dir.remapped; 176 agp_bridge->gatt_table = (u32 __iomem *)page_dir.remapped;
177 agp_bridge->gatt_bus_addr = virt_to_phys(page_dir.real); 177 agp_bridge->gatt_bus_addr = virt_to_gart(page_dir.real);
178 178
179 /* Get the address for the gart region. 179 /* Get the address for the gart region.
180 * This is a bus address even on the alpha, b/c its 180 * This is a bus address even on the alpha, b/c its
@@ -187,7 +187,7 @@ static int serverworks_create_gatt_table(struct agp_bridge_data *bridge)
187 /* Calculate the agp offset */ 187 /* Calculate the agp offset */
188 188
189 for(i = 0; i < value->num_entries / 1024; i++) 189 for(i = 0; i < value->num_entries / 1024; i++)
190 writel(virt_to_phys(serverworks_private.gatt_pages[i]->real)|1, page_dir.remapped+i); 190 writel(virt_to_gart(serverworks_private.gatt_pages[i]->real)|1, page_dir.remapped+i);
191 191
192 return 0; 192 return 0;
193} 193}
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index a673971f2a90..c8255312b8c1 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -407,7 +407,7 @@ static int uninorth_create_gatt_table(struct agp_bridge_data *bridge)
407 407
408 bridge->gatt_table_real = (u32 *) table; 408 bridge->gatt_table_real = (u32 *) table;
409 bridge->gatt_table = (u32 *)table; 409 bridge->gatt_table = (u32 *)table;
410 bridge->gatt_bus_addr = virt_to_phys(table); 410 bridge->gatt_bus_addr = virt_to_gart(table);
411 411
412 for (i = 0; i < num_entries; i++) 412 for (i = 0; i < num_entries; i++)
413 bridge->gatt_table[i] = 0; 413 bridge->gatt_table[i] = 0;
diff --git a/include/asm-alpha/agp.h b/include/asm-alpha/agp.h
index c99dbbb5bcb5..ef855a3bc0f5 100644
--- a/include/asm-alpha/agp.h
+++ b/include/asm-alpha/agp.h
@@ -10,4 +10,14 @@
10#define flush_agp_mappings() 10#define flush_agp_mappings()
11#define flush_agp_cache() mb() 11#define flush_agp_cache() mb()
12 12
13/* Convert a physical address to an address suitable for the GART. */
14#define phys_to_gart(x) (x)
15#define gart_to_phys(x) (x)
16
17/* GATT allocation. Returns/accepts GATT kernel virtual address. */
18#define alloc_gatt_pages(order) \
19 ((char *)__get_free_pages(GFP_KERNEL, (order)))
20#define free_gatt_pages(table, order) \
21 free_pages((unsigned long)(table), (order))
22
13#endif 23#endif
diff --git a/include/asm-i386/agp.h b/include/asm-i386/agp.h
index a917ff50354f..b82f5f3ab887 100644
--- a/include/asm-i386/agp.h
+++ b/include/asm-i386/agp.h
@@ -21,4 +21,14 @@ int unmap_page_from_agp(struct page *page);
21 worth it. Would need a page for it. */ 21 worth it. Would need a page for it. */
22#define flush_agp_cache() asm volatile("wbinvd":::"memory") 22#define flush_agp_cache() asm volatile("wbinvd":::"memory")
23 23
24/* Convert a physical address to an address suitable for the GART. */
25#define phys_to_gart(x) (x)
26#define gart_to_phys(x) (x)
27
28/* GATT allocation. Returns/accepts GATT kernel virtual address. */
29#define alloc_gatt_pages(order) \
30 ((char *)__get_free_pages(GFP_KERNEL, (order)))
31#define free_gatt_pages(table, order) \
32 free_pages((unsigned long)(table), (order))
33
24#endif 34#endif
diff --git a/include/asm-ia64/agp.h b/include/asm-ia64/agp.h
index d1316f1e6ee1..4e517f0e6afa 100644
--- a/include/asm-ia64/agp.h
+++ b/include/asm-ia64/agp.h
@@ -18,4 +18,14 @@
18#define flush_agp_mappings() /* nothing */ 18#define flush_agp_mappings() /* nothing */
19#define flush_agp_cache() mb() 19#define flush_agp_cache() mb()
20 20
21/* Convert a physical address to an address suitable for the GART. */
22#define phys_to_gart(x) (x)
23#define gart_to_phys(x) (x)
24
25/* GATT allocation. Returns/accepts GATT kernel virtual address. */
26#define alloc_gatt_pages(order) \
27 ((char *)__get_free_pages(GFP_KERNEL, (order)))
28#define free_gatt_pages(table, order) \
29 free_pages((unsigned long)(table), (order))
30
21#endif /* _ASM_IA64_AGP_H */ 31#endif /* _ASM_IA64_AGP_H */
diff --git a/include/asm-ppc/agp.h b/include/asm-ppc/agp.h
index be27cfa8c5b0..ca9e423307f4 100644
--- a/include/asm-ppc/agp.h
+++ b/include/asm-ppc/agp.h
@@ -10,4 +10,14 @@
10#define flush_agp_mappings() 10#define flush_agp_mappings()
11#define flush_agp_cache() mb() 11#define flush_agp_cache() mb()
12 12
13/* Convert a physical address to an address suitable for the GART. */
14#define phys_to_gart(x) (x)
15#define gart_to_phys(x) (x)
16
17/* GATT allocation. Returns/accepts GATT kernel virtual address. */
18#define alloc_gatt_pages(order) \
19 ((char *)__get_free_pages(GFP_KERNEL, (order)))
20#define free_gatt_pages(table, order) \
21 free_pages((unsigned long)(table), (order))
22
13#endif 23#endif
diff --git a/include/asm-ppc64/agp.h b/include/asm-ppc64/agp.h
index be27cfa8c5b0..ca9e423307f4 100644
--- a/include/asm-ppc64/agp.h
+++ b/include/asm-ppc64/agp.h
@@ -10,4 +10,14 @@
10#define flush_agp_mappings() 10#define flush_agp_mappings()
11#define flush_agp_cache() mb() 11#define flush_agp_cache() mb()
12 12
13/* Convert a physical address to an address suitable for the GART. */
14#define phys_to_gart(x) (x)
15#define gart_to_phys(x) (x)
16
17/* GATT allocation. Returns/accepts GATT kernel virtual address. */
18#define alloc_gatt_pages(order) \
19 ((char *)__get_free_pages(GFP_KERNEL, (order)))
20#define free_gatt_pages(table, order) \
21 free_pages((unsigned long)(table), (order))
22
13#endif 23#endif
diff --git a/include/asm-sparc64/agp.h b/include/asm-sparc64/agp.h
index ba05bdf9a211..58f8cb6ae767 100644
--- a/include/asm-sparc64/agp.h
+++ b/include/asm-sparc64/agp.h
@@ -8,4 +8,14 @@
8#define flush_agp_mappings() 8#define flush_agp_mappings()
9#define flush_agp_cache() mb() 9#define flush_agp_cache() mb()
10 10
11/* Convert a physical address to an address suitable for the GART. */
12#define phys_to_gart(x) (x)
13#define gart_to_phys(x) (x)
14
15/* GATT allocation. Returns/accepts GATT kernel virtual address. */
16#define alloc_gatt_pages(order) \
17 ((char *)__get_free_pages(GFP_KERNEL, (order)))
18#define free_gatt_pages(table, order) \
19 free_pages((unsigned long)(table), (order))
20
11#endif 21#endif
diff --git a/include/asm-x86_64/agp.h b/include/asm-x86_64/agp.h
index 0bb9019d58aa..06c52ee9c06b 100644
--- a/include/asm-x86_64/agp.h
+++ b/include/asm-x86_64/agp.h
@@ -19,4 +19,14 @@ int unmap_page_from_agp(struct page *page);
19 worth it. Would need a page for it. */ 19 worth it. Would need a page for it. */
20#define flush_agp_cache() asm volatile("wbinvd":::"memory") 20#define flush_agp_cache() asm volatile("wbinvd":::"memory")
21 21
22/* Convert a physical address to an address suitable for the GART. */
23#define phys_to_gart(x) (x)
24#define gart_to_phys(x) (x)
25
26/* GATT allocation. Returns/accepts GATT kernel virtual address. */
27#define alloc_gatt_pages(order) \
28 ((char *)__get_free_pages(GFP_KERNEL, (order)))
29#define free_gatt_pages(table, order) \
30 free_pages((unsigned long)(table), (order))
31
22#endif 32#endif