aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2009-07-27 05:27:29 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2009-08-03 04:04:44 -0400
commit2a4ceb6d3e6a566cb4a9dc8f974177f031d27cd7 (patch)
treea21d2c5ad10522d9a1469e7cd985d5f1d8f5d17f /drivers
parented680c4ad478d0fee9740f7d029087f181346564 (diff)
agp: Switch mask_memory() method to take address argument again, not page
In commit 07613ba2 ("agp: switch AGP to use page array instead of unsigned long array") we switched the mask_memory() method to take a 'struct page *' instead of an address. This is painful, because in some cases it has to be an IOMMU-mapped virtual bus address (in fact, shouldn't it _always_ be a dma_addr_t returned from pci_map_xxx(), and we just happen to get lucky most of the time?) Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/agp/agp.h4
-rw-r--r--drivers/char/agp/amd-k7-agp.c4
-rw-r--r--drivers/char/agp/amd64-agp.c3
-rw-r--r--drivers/char/agp/ati-agp.c3
-rw-r--r--drivers/char/agp/backend.c4
-rw-r--r--drivers/char/agp/generic.c7
-rw-r--r--drivers/char/agp/hp-agp.c4
-rw-r--r--drivers/char/agp/i460-agp.c13
-rw-r--r--drivers/char/agp/intel-agp.c14
-rw-r--r--drivers/char/agp/nvidia-agp.c2
-rw-r--r--drivers/char/agp/parisc-agp.c12
-rw-r--r--drivers/char/agp/sgi-agp.c8
-rw-r--r--drivers/char/agp/sworks-agp.c4
13 files changed, 36 insertions, 46 deletions
diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h
index 178e2e9e9f09..ce110a3bf298 100644
--- a/drivers/char/agp/agp.h
+++ b/drivers/char/agp/agp.h
@@ -107,7 +107,7 @@ struct agp_bridge_driver {
107 void (*agp_enable)(struct agp_bridge_data *, u32); 107 void (*agp_enable)(struct agp_bridge_data *, u32);
108 void (*cleanup)(void); 108 void (*cleanup)(void);
109 void (*tlb_flush)(struct agp_memory *); 109 void (*tlb_flush)(struct agp_memory *);
110 unsigned long (*mask_memory)(struct agp_bridge_data *, struct page *, int); 110 unsigned long (*mask_memory)(struct agp_bridge_data *, dma_addr_t, int);
111 void (*cache_flush)(void); 111 void (*cache_flush)(void);
112 int (*create_gatt_table)(struct agp_bridge_data *); 112 int (*create_gatt_table)(struct agp_bridge_data *);
113 int (*free_gatt_table)(struct agp_bridge_data *); 113 int (*free_gatt_table)(struct agp_bridge_data *);
@@ -291,7 +291,7 @@ int agp_3_5_enable(struct agp_bridge_data *bridge);
291void global_cache_flush(void); 291void global_cache_flush(void);
292void get_agp_version(struct agp_bridge_data *bridge); 292void get_agp_version(struct agp_bridge_data *bridge);
293unsigned long agp_generic_mask_memory(struct agp_bridge_data *bridge, 293unsigned long agp_generic_mask_memory(struct agp_bridge_data *bridge,
294 struct page *page, int type); 294 dma_addr_t phys, int type);
295int agp_generic_type_to_mask_type(struct agp_bridge_data *bridge, 295int agp_generic_type_to_mask_type(struct agp_bridge_data *bridge,
296 int type); 296 int type);
297struct agp_bridge_data *agp_generic_find_bridge(struct pci_dev *pdev); 297struct agp_bridge_data *agp_generic_find_bridge(struct pci_dev *pdev);
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c
index ba9bde71eaaf..542a87895ae9 100644
--- a/drivers/char/agp/amd-k7-agp.c
+++ b/drivers/char/agp/amd-k7-agp.c
@@ -325,7 +325,9 @@ static int amd_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
325 addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr; 325 addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr;
326 cur_gatt = GET_GATT(addr); 326 cur_gatt = GET_GATT(addr);
327 writel(agp_generic_mask_memory(agp_bridge, 327 writel(agp_generic_mask_memory(agp_bridge,
328 mem->pages[i], mem->type), cur_gatt+GET_GATT_OFF(addr)); 328 phys_to_gart(page_to_phys(mem->pages[i])),
329 mem->type),
330 cur_gatt+GET_GATT_OFF(addr));
329 readl(cur_gatt+GET_GATT_OFF(addr)); /* PCI Posting. */ 331 readl(cur_gatt+GET_GATT_OFF(addr)); /* PCI Posting. */
330 } 332 }
331 amd_irongate_tlbflush(mem); 333 amd_irongate_tlbflush(mem);
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 3bf5dda90f4a..e85a5b3e952e 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -79,7 +79,8 @@ static int amd64_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
79 79
80 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 80 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
81 tmp = agp_bridge->driver->mask_memory(agp_bridge, 81 tmp = agp_bridge->driver->mask_memory(agp_bridge,
82 mem->pages[i], mask_type); 82 phys_to_gart(page_to_phys(mem->pages[i])),
83 mask_type);
83 84
84 BUG_ON(tmp & 0xffffff0000000ffcULL); 85 BUG_ON(tmp & 0xffffff0000000ffcULL);
85 pte = (tmp & 0x000000ff00000000ULL) >> 28; 86 pte = (tmp & 0x000000ff00000000ULL) >> 28;
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
index 33656e144cc5..59ebd60c1b60 100644
--- a/drivers/char/agp/ati-agp.c
+++ b/drivers/char/agp/ati-agp.c
@@ -302,7 +302,8 @@ static int ati_insert_memory(struct agp_memory * mem,
302 addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr; 302 addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr;
303 cur_gatt = GET_GATT(addr); 303 cur_gatt = GET_GATT(addr);
304 writel(agp_bridge->driver->mask_memory(agp_bridge, 304 writel(agp_bridge->driver->mask_memory(agp_bridge,
305 mem->pages[i], mem->type), 305 phys_to_gart(page_to_phys(mem->pages[i])),
306 mem->type),
306 cur_gatt+GET_GATT_OFF(addr)); 307 cur_gatt+GET_GATT_OFF(addr));
307 } 308 }
308 readl(GET_GATT(agp_bridge->gart_bus_addr)); /* PCI posting */ 309 readl(GET_GATT(agp_bridge->gart_bus_addr)); /* PCI posting */
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
index cfa5a649dfe7..3bd7e503de41 100644
--- a/drivers/char/agp/backend.c
+++ b/drivers/char/agp/backend.c
@@ -150,8 +150,8 @@ static int agp_backend_initialize(struct agp_bridge_data *bridge)
150 } 150 }
151 151
152 bridge->scratch_page_real = phys_to_gart(page_to_phys(page)); 152 bridge->scratch_page_real = phys_to_gart(page_to_phys(page));
153 bridge->scratch_page = 153 bridge->scratch_page = bridge->driver->mask_memory(bridge,
154 bridge->driver->mask_memory(bridge, page, 0); 154 phys_to_gart(page_to_phys(page)), 0);
155 } 155 }
156 156
157 size_value = bridge->driver->fetch_size(); 157 size_value = bridge->driver->fetch_size();
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index 1e8b461b91f1..a3bcc7ef42f9 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -1132,7 +1132,9 @@ int agp_generic_insert_memory(struct agp_memory * mem, off_t pg_start, int type)
1132 } 1132 }
1133 1133
1134 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 1134 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
1135 writel(bridge->driver->mask_memory(bridge, mem->pages[i], mask_type), 1135 writel(bridge->driver->mask_memory(bridge,
1136 phys_to_gart(page_to_phys(mem->pages[i])),
1137 mask_type),
1136 bridge->gatt_table+j); 1138 bridge->gatt_table+j);
1137 } 1139 }
1138 readl(bridge->gatt_table+j-1); /* PCI Posting. */ 1140 readl(bridge->gatt_table+j-1); /* PCI Posting. */
@@ -1347,9 +1349,8 @@ void global_cache_flush(void)
1347EXPORT_SYMBOL(global_cache_flush); 1349EXPORT_SYMBOL(global_cache_flush);
1348 1350
1349unsigned long agp_generic_mask_memory(struct agp_bridge_data *bridge, 1351unsigned long agp_generic_mask_memory(struct agp_bridge_data *bridge,
1350 struct page *page, int type) 1352 dma_addr_t addr, int type)
1351{ 1353{
1352 unsigned long addr = phys_to_gart(page_to_phys(page));
1353 /* memory type is ignored in the generic routine */ 1354 /* memory type is ignored in the generic routine */
1354 if (bridge->driver->masks) 1355 if (bridge->driver->masks)
1355 return addr | bridge->driver->masks[0].mask; 1356 return addr | bridge->driver->masks[0].mask;
diff --git a/drivers/char/agp/hp-agp.c b/drivers/char/agp/hp-agp.c
index 8f3d4c184914..64dbf4b1cf2f 100644
--- a/drivers/char/agp/hp-agp.c
+++ b/drivers/char/agp/hp-agp.c
@@ -394,10 +394,8 @@ hp_zx1_remove_memory (struct agp_memory *mem, off_t pg_start, int type)
394} 394}
395 395
396static unsigned long 396static unsigned long
397hp_zx1_mask_memory (struct agp_bridge_data *bridge, 397hp_zx1_mask_memory (struct agp_bridge_data *bridge, dma_addr_t addr, int type)
398 struct page *page, int type)
399{ 398{
400 unsigned long addr = phys_to_gart(page_to_phys(page));
401 return HP_ZX1_PDIR_VALID_BIT | addr; 399 return HP_ZX1_PDIR_VALID_BIT | addr;
402} 400}
403 401
diff --git a/drivers/char/agp/i460-agp.c b/drivers/char/agp/i460-agp.c
index 60cc35bb5db7..54191f860539 100644
--- a/drivers/char/agp/i460-agp.c
+++ b/drivers/char/agp/i460-agp.c
@@ -61,7 +61,7 @@
61#define WR_FLUSH_GATT(index) RD_GATT(index) 61#define WR_FLUSH_GATT(index) RD_GATT(index)
62 62
63static unsigned long i460_mask_memory (struct agp_bridge_data *bridge, 63static unsigned long i460_mask_memory (struct agp_bridge_data *bridge,
64 unsigned long addr, int type); 64 dma_addr_t addr, int type);
65 65
66static struct { 66static struct {
67 void *gatt; /* ioremap'd GATT area */ 67 void *gatt; /* ioremap'd GATT area */
@@ -546,20 +546,13 @@ static void i460_destroy_page (struct page *page, int flags)
546#endif /* I460_LARGE_IO_PAGES */ 546#endif /* I460_LARGE_IO_PAGES */
547 547
548static unsigned long i460_mask_memory (struct agp_bridge_data *bridge, 548static unsigned long i460_mask_memory (struct agp_bridge_data *bridge,
549 unsigned long addr, int type) 549 dma_addr_t addr, int type)
550{ 550{
551 /* Make sure the returned address is a valid GATT entry */ 551 /* Make sure the returned address is a valid GATT entry */
552 return bridge->driver->masks[0].mask 552 return bridge->driver->masks[0].mask
553 | (((addr & ~((1 << I460_IO_PAGE_SHIFT) - 1)) & 0xfffff000) >> 12); 553 | (((addr & ~((1 << I460_IO_PAGE_SHIFT) - 1)) & 0xfffff000) >> 12);
554} 554}
555 555
556static unsigned long i460_page_mask_memory(struct agp_bridge_data *bridge,
557 struct page *page, int type)
558{
559 unsigned long addr = phys_to_gart(page_to_phys(page));
560 return i460_mask_memory(bridge, addr, type);
561}
562
563const struct agp_bridge_driver intel_i460_driver = { 556const struct agp_bridge_driver intel_i460_driver = {
564 .owner = THIS_MODULE, 557 .owner = THIS_MODULE,
565 .aperture_sizes = i460_sizes, 558 .aperture_sizes = i460_sizes,
@@ -569,7 +562,7 @@ const struct agp_bridge_driver intel_i460_driver = {
569 .fetch_size = i460_fetch_size, 562 .fetch_size = i460_fetch_size,
570 .cleanup = i460_cleanup, 563 .cleanup = i460_cleanup,
571 .tlb_flush = i460_tlb_flush, 564 .tlb_flush = i460_tlb_flush,
572 .mask_memory = i460_page_mask_memory, 565 .mask_memory = i460_mask_memory,
573 .masks = i460_masks, 566 .masks = i460_masks,
574 .agp_enable = agp_generic_enable, 567 .agp_enable = agp_generic_enable,
575 .cache_flush = global_cache_flush, 568 .cache_flush = global_cache_flush,
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 8c9d50db5c3a..21983456d672 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -343,7 +343,7 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
343 global_cache_flush(); 343 global_cache_flush();
344 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 344 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
345 writel(agp_bridge->driver->mask_memory(agp_bridge, 345 writel(agp_bridge->driver->mask_memory(agp_bridge,
346 mem->pages[i], 346 phys_to_gart(page_to_phys(mem->pages[i])),
347 mask_type), 347 mask_type),
348 intel_private.registers+I810_PTE_BASE+(j*4)); 348 intel_private.registers+I810_PTE_BASE+(j*4));
349 } 349 }
@@ -461,9 +461,8 @@ static void intel_i810_free_by_type(struct agp_memory *curr)
461} 461}
462 462
463static unsigned long intel_i810_mask_memory(struct agp_bridge_data *bridge, 463static unsigned long intel_i810_mask_memory(struct agp_bridge_data *bridge,
464 struct page *page, int type) 464 dma_addr_t addr, int type)
465{ 465{
466 unsigned long addr = phys_to_gart(page_to_phys(page));
467 /* Type checking must be done elsewhere */ 466 /* Type checking must be done elsewhere */
468 return addr | bridge->driver->masks[type].mask; 467 return addr | bridge->driver->masks[type].mask;
469} 468}
@@ -851,7 +850,7 @@ static int intel_i830_insert_entries(struct agp_memory *mem, off_t pg_start,
851 850
852 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 851 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
853 writel(agp_bridge->driver->mask_memory(agp_bridge, 852 writel(agp_bridge->driver->mask_memory(agp_bridge,
854 mem->pages[i], mask_type), 853 phys_to_gart(page_to_phys(mem->pages[i])), mask_type),
855 intel_private.registers+I810_PTE_BASE+(j*4)); 854 intel_private.registers+I810_PTE_BASE+(j*4));
856 } 855 }
857 readl(intel_private.registers+I810_PTE_BASE+((j-1)*4)); 856 readl(intel_private.registers+I810_PTE_BASE+((j-1)*4));
@@ -1081,7 +1080,9 @@ static int intel_i915_insert_entries(struct agp_memory *mem, off_t pg_start,
1081 1080
1082 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 1081 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
1083 writel(agp_bridge->driver->mask_memory(agp_bridge, 1082 writel(agp_bridge->driver->mask_memory(agp_bridge,
1084 mem->pages[i], mask_type), intel_private.gtt+j); 1083 phys_to_gart(page_to_phys(mem->pages[i])),
1084 mask_type),
1085 intel_private.gtt+j);
1085 } 1086 }
1086 1087
1087 readl(intel_private.gtt+j-1); 1088 readl(intel_private.gtt+j-1);
@@ -1196,9 +1197,8 @@ static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge)
1196 * this conditional. 1197 * this conditional.
1197 */ 1198 */
1198static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge, 1199static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge,
1199 struct page *page, int type) 1200 dma_addr_t addr, int type)
1200{ 1201{
1201 dma_addr_t addr = phys_to_gart(page_to_phys(page));
1202 /* Shift high bits down */ 1202 /* Shift high bits down */
1203 addr |= (addr >> 28) & 0xf0; 1203 addr |= (addr >> 28) & 0xf0;
1204 1204
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index 263d71dd441c..cedacee30ec3 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -225,7 +225,7 @@ static int nvidia_insert_memory(struct agp_memory *mem, off_t pg_start, int type
225 } 225 }
226 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 226 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
227 writel(agp_bridge->driver->mask_memory(agp_bridge, 227 writel(agp_bridge->driver->mask_memory(agp_bridge,
228 mem->pages[i], mask_type), 228 phys_to_gart(page_to_phys(mem->pages[i])), mask_type),
229 agp_bridge->gatt_table+nvidia_private.pg_offset+j); 229 agp_bridge->gatt_table+nvidia_private.pg_offset+j);
230 } 230 }
231 231
diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c
index f4bb43fb8016..1c129211302d 100644
--- a/drivers/char/agp/parisc-agp.c
+++ b/drivers/char/agp/parisc-agp.c
@@ -32,7 +32,7 @@
32#define AGP8X_MODE (1 << AGP8X_MODE_BIT) 32#define AGP8X_MODE (1 << AGP8X_MODE_BIT)
33 33
34static unsigned long 34static unsigned long
35parisc_agp_mask_memory(struct agp_bridge_data *bridge, unsigned long addr, 35parisc_agp_mask_memory(struct agp_bridge_data *bridge, dma_addr_t addr,
36 int type); 36 int type);
37 37
38static struct _parisc_agp_info { 38static struct _parisc_agp_info {
@@ -189,20 +189,12 @@ parisc_agp_remove_memory(struct agp_memory *mem, off_t pg_start, int type)
189} 189}
190 190
191static unsigned long 191static unsigned long
192parisc_agp_mask_memory(struct agp_bridge_data *bridge, unsigned long addr, 192parisc_agp_mask_memory(struct agp_bridge_data *bridge, dma_addr_t addr,
193 int type) 193 int type)
194{ 194{
195 return SBA_PDIR_VALID_BIT | addr; 195 return SBA_PDIR_VALID_BIT | addr;
196} 196}
197 197
198static unsigned long
199parisc_agp_page_mask_memory(struct agp_bridge_data *bridge, struct page *page,
200 int type)
201{
202 unsigned long addr = phys_to_gart(page_to_phys(page));
203 return SBA_PDIR_VALID_BIT | addr;
204}
205
206static void 198static void
207parisc_agp_enable(struct agp_bridge_data *bridge, u32 mode) 199parisc_agp_enable(struct agp_bridge_data *bridge, u32 mode)
208{ 200{
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c
index d3ea2e4226b5..0d47fa847404 100644
--- a/drivers/char/agp/sgi-agp.c
+++ b/drivers/char/agp/sgi-agp.c
@@ -70,10 +70,9 @@ static void sgi_tioca_tlbflush(struct agp_memory *mem)
70 * entry. 70 * entry.
71 */ 71 */
72static unsigned long 72static unsigned long
73sgi_tioca_mask_memory(struct agp_bridge_data *bridge, 73sgi_tioca_mask_memory(struct agp_bridge_data *bridge, dma_addr_t addr,
74 struct page *page, int type) 74 int type)
75{ 75{
76 unsigned long addr = phys_to_gart(page_to_phys(page));
77 return tioca_physpage_to_gart(addr); 76 return tioca_physpage_to_gart(addr);
78} 77}
79 78
@@ -190,7 +189,8 @@ static int sgi_tioca_insert_memory(struct agp_memory *mem, off_t pg_start,
190 189
191 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 190 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
192 table[j] = 191 table[j] =
193 bridge->driver->mask_memory(bridge, mem->pages[i], 192 bridge->driver->mask_memory(bridge,
193 phys_to_gart(page_to_phys(mem->pages[i])),
194 mem->type); 194 mem->type);
195 } 195 }
196 196
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c
index b964a2199329..07259952fc32 100644
--- a/drivers/char/agp/sworks-agp.c
+++ b/drivers/char/agp/sworks-agp.c
@@ -349,7 +349,9 @@ static int serverworks_insert_memory(struct agp_memory *mem,
349 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 349 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
350 addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr; 350 addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr;
351 cur_gatt = SVRWRKS_GET_GATT(addr); 351 cur_gatt = SVRWRKS_GET_GATT(addr);
352 writel(agp_bridge->driver->mask_memory(agp_bridge, mem->pages[i], mem->type), cur_gatt+GET_GATT_OFF(addr)); 352 writel(agp_bridge->driver->mask_memory(agp_bridge,
353 phys_to_gart(page_to_phys(mem->pages[i])), mem->type),
354 cur_gatt+GET_GATT_OFF(addr));
353 } 355 }
354 serverworks_tlbflush(mem); 356 serverworks_tlbflush(mem);
355 return 0; 357 return 0;