aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/agp/generic.c
diff options
context:
space:
mode:
authorShaohua Li <shaohua.li@intel.com>2008-08-20 22:46:17 -0400
committerIngo Molnar <mingo@elte.hu>2008-08-21 07:47:46 -0400
commitbd07928c0f9c3dbe53baf28eae4de4c579772c4c (patch)
tree7210c0a3c96bd58517ba45365ef87092394870b4 /drivers/char/agp/generic.c
parent37acee10f49cf3caa323e05675e8dc9221ef4fd8 (diff)
agp: add agp_generic_destroy_pages()
Add agp_generic_destroy_pages(), it uses new pageattr array interface API. Signed-off-by: Dave Airlie <airlied@gmail.com> Signed-off-by: Shaohua Li <shaohua.li@intel.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers/char/agp/generic.c')
-rw-r--r--drivers/char/agp/generic.c55
1 files changed, 47 insertions, 8 deletions
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index 13a5577ee434..dd370be00d68 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -201,14 +201,22 @@ void agp_free_memory(struct agp_memory *curr)
201 return; 201 return;
202 } 202 }
203 if (curr->page_count != 0) { 203 if (curr->page_count != 0) {
204 for (i = 0; i < curr->page_count; i++) { 204 if (curr->bridge->driver->agp_destroy_pages) {
205 curr->memory[i] = (unsigned long)gart_to_virt(curr->memory[i]); 205 curr->bridge->driver->agp_destroy_pages(curr);
206 curr->bridge->driver->agp_destroy_page((void *)curr->memory[i], 206 } else {
207 AGP_PAGE_DESTROY_UNMAP); 207
208 } 208 for (i = 0; i < curr->page_count; i++) {
209 for (i = 0; i < curr->page_count; i++) { 209 curr->memory[i] = (unsigned long)gart_to_virt(
210 curr->bridge->driver->agp_destroy_page((void *)curr->memory[i], 210 curr->memory[i]);
211 AGP_PAGE_DESTROY_FREE); 211 curr->bridge->driver->agp_destroy_page(
212 (void *)curr->memory[i],
213 AGP_PAGE_DESTROY_UNMAP);
214 }
215 for (i = 0; i < curr->page_count; i++) {
216 curr->bridge->driver->agp_destroy_page(
217 (void *)curr->memory[i],
218 AGP_PAGE_DESTROY_FREE);
219 }
212 } 220 }
213 } 221 }
214 agp_free_key(curr->key); 222 agp_free_key(curr->key);
@@ -1236,6 +1244,37 @@ void *agp_generic_alloc_page(struct agp_bridge_data *bridge)
1236} 1244}
1237EXPORT_SYMBOL(agp_generic_alloc_page); 1245EXPORT_SYMBOL(agp_generic_alloc_page);
1238 1246
1247void agp_generic_destroy_pages(struct agp_memory *mem)
1248{
1249 int i;
1250 void *addr;
1251 struct page *page;
1252
1253 if (!mem)
1254 return;
1255
1256 for (i = 0; i < mem->page_count; i++)
1257 mem->memory[i] = (unsigned long)gart_to_virt(mem->memory[i]);
1258
1259#ifdef CONFIG_X86
1260 set_memory_array_wb(mem->memory, mem->page_count);
1261#endif
1262
1263 for (i = 0; i < mem->page_count; i++) {
1264 addr = (void *)mem->memory[i];
1265 page = virt_to_page(addr);
1266
1267#ifndef CONFIG_X86
1268 unmap_page_from_agp(page);
1269#endif
1270
1271 put_page(page);
1272 free_page((unsigned long)addr);
1273 atomic_dec(&agp_bridge->current_memory_agp);
1274 mem->memory[i] = 0;
1275 }
1276}
1277EXPORT_SYMBOL(agp_generic_destroy_pages);
1239 1278
1240void agp_generic_destroy_page(void *addr, int flags) 1279void agp_generic_destroy_page(void *addr, int flags)
1241{ 1280{