Skip to content

Commit

Permalink
reduce tlb/cache flush times of agpgart memory allocation
Browse files Browse the repository at this point in the history
To reduce tlb/cache flush, makes agp memory allocation do one flush
after all pages in a region are changed to uc.

All agp drivers except agp-sgi uses agp_generic_alloc_page()
for .agp_alloc_page, so the patch should work for them. agp-sgi is only
for ia64, so not a problem too.

Signed-off-by: Shaohua Li <shaohua.li@intel.com>
Cc: airlied@linux.ie
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Shaohua Li authored and Ingo Molnar committed Aug 15, 2008
1 parent 1ac2f7d commit 466ae83
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions drivers/char/agp/agp.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#define _AGP_BACKEND_PRIV_H 1

#include <asm/agp.h> /* for flush_agp_cache() */
#ifndef map_page_into_agp_noflush
#define map_page_into_agp_noflush(page) map_page_into_agp(page)
#define map_page_into_agp_global_flush()
#endif

#define PFX "agpgart: "

Expand Down
4 changes: 3 additions & 1 deletion drivers/char/agp/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ struct agp_memory *agp_allocate_memory(struct agp_bridge_data *bridge,
new->memory[i] = virt_to_gart(addr);
new->page_count++;
}
map_page_into_agp_global_flush();
new->bridge = bridge;

return new;
Expand Down Expand Up @@ -1186,7 +1187,8 @@ void *agp_generic_alloc_page(struct agp_bridge_data *bridge)
if (page == NULL)
return NULL;

map_page_into_agp(page);
/* agp_allocate_memory will do flush */
map_page_into_agp_noflush(page);

get_page(page);
atomic_inc(&agp_bridge->current_memory_agp);
Expand Down
3 changes: 3 additions & 0 deletions include/asm-x86/agp.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#define map_page_into_agp(page) set_pages_uc(page, 1)
#define unmap_page_from_agp(page) set_pages_wb(page, 1)

#define map_page_into_agp_noflush(page) set_pages_uc_noflush(page, 1)
#define map_page_into_agp_global_flush() set_memory_flush_all()

/*
* Could use CLFLUSH here if the cpu supports it. But then it would
* need to be called for each cacheline of the whole page so it may
Expand Down

0 comments on commit 466ae83

Please sign in to comment.