Merge git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86
[sfrench/cifs-2.6.git] / drivers / char / agp / generic.c
index d535c406b3192512433130cc3109a4d3cd77bfe2..7fc0c99a3a5850cc939cbe8e3909840c0748c3d6 100644 (file)
@@ -80,6 +80,13 @@ static int agp_get_key(void)
        return -1;
 }
 
+void agp_flush_chipset(struct agp_bridge_data *bridge)
+{
+       if (bridge->driver->chipset_flush)
+               bridge->driver->chipset_flush(bridge);
+}
+EXPORT_SYMBOL(agp_flush_chipset);
+
 /*
  * Use kmalloc if possible for the page list. Otherwise fall back to
  * vmalloc. This speeds things up and also saves memory for small AGP
@@ -195,9 +202,11 @@ void agp_free_memory(struct agp_memory *curr)
        }
        if (curr->page_count != 0) {
                for (i = 0; i < curr->page_count; i++) {
-                       curr->bridge->driver->agp_destroy_page(gart_to_virt(curr->memory[i]));
+                       curr->bridge->driver->agp_destroy_page(gart_to_virt(curr->memory[i]), AGP_PAGE_DESTROY_UNMAP);
+               }
+               for (i = 0; i < curr->page_count; i++) {
+                       curr->bridge->driver->agp_destroy_page(gart_to_virt(curr->memory[i]), AGP_PAGE_DESTROY_FREE);
                }
-               flush_agp_mappings();
        }
        agp_free_key(curr->key);
        agp_free_page_array(curr);
@@ -264,8 +273,6 @@ struct agp_memory *agp_allocate_memory(struct agp_bridge_data *bridge,
        }
        new->bridge = bridge;
 
-       flush_agp_mappings();
-
        return new;
 }
 EXPORT_SYMBOL(agp_allocate_memory);
@@ -925,9 +932,14 @@ int agp_generic_create_gatt_table(struct agp_bridge_data *bridge)
        agp_gatt_table = (void *)table;
 
        bridge->driver->cache_flush();
+#ifdef CONFIG_X86
+       set_memory_uc((unsigned long)table, 1 << page_order);
+       bridge->gatt_table = (void *)table;
+#else
        bridge->gatt_table = ioremap_nocache(virt_to_gart(table),
                                        (PAGE_SIZE * (1 << page_order)));
        bridge->driver->cache_flush();
+#endif
 
        if (bridge->gatt_table == NULL) {
                for (page = virt_to_page(table); page <= virt_to_page(table_end); page++)
@@ -984,7 +996,11 @@ int agp_generic_free_gatt_table(struct agp_bridge_data *bridge)
         * called, then all agp memory is deallocated and removed
         * from the table. */
 
+#ifdef CONFIG_X86
+       set_memory_wb((unsigned long)bridge->gatt_table, 1 << page_order);
+#else
        iounmap(bridge->gatt_table);
+#endif
        table = (char *) bridge->gatt_table_real;
        table_end = table + ((PAGE_SIZE * (1 << page_order)) - 1);
 
@@ -1170,14 +1186,13 @@ void *agp_generic_alloc_page(struct agp_bridge_data *bridge)
        map_page_into_agp(page);
 
        get_page(page);
-       SetPageLocked(page);
        atomic_inc(&agp_bridge->current_memory_agp);
        return page_address(page);
 }
 EXPORT_SYMBOL(agp_generic_alloc_page);
 
 
-void agp_generic_destroy_page(void *addr)
+void agp_generic_destroy_page(void *addr, int flags)
 {
        struct page *page;
 
@@ -1185,11 +1200,14 @@ void agp_generic_destroy_page(void *addr)
                return;
 
        page = virt_to_page(addr);
-       unmap_page_from_agp(page);
-       put_page(page);
-       unlock_page(page);
-       free_page((unsigned long)addr);
-       atomic_dec(&agp_bridge->current_memory_agp);
+       if (flags & AGP_PAGE_DESTROY_UNMAP)
+               unmap_page_from_agp(page);
+
+       if (flags & AGP_PAGE_DESTROY_FREE) {
+               put_page(page);
+               free_page((unsigned long)addr);
+               atomic_dec(&agp_bridge->current_memory_agp);
+       }
 }
 EXPORT_SYMBOL(agp_generic_destroy_page);