linux: fix agp address handling, namely intel-agp
PATCH 1/1 linux: fix agp address handling, namely intel-agp
Make sure machine addresses are in fact constrained to 32 bits, and assumptions about multi-page extents being contiguous are being met.
Generic parts of the patch are in 2.6.22-rc4, but it was not tested against 2.6.18.
Signed-off-by Jan Beulich <[email protected]>
drivers/char/agp/generic.c +0 -22
@@ -51,28 +51,6 @@ int agp_memory_reserved;*/ EXPORT_SYMBOL_GPL (agp_memory_reserved); -#if defined(CONFIG_X86 ) -int map_page_into_agp (struct page *page) -{ -int i; - i =change_page_attr (page,1 ,PAGE_KERNEL_NOCACHE ); -/* Caller's responsibility to call global_flush_tlb() for -* performance reasons */ -return i; -} -EXPORT_SYMBOL_GPL (map_page_into_agp); - -int unmap_page_from_agp (struct page *page) -{ -int i; - i =change_page_attr (page,1 ,PAGE_KERNEL ); -/* Caller's responsibility to call global_flush_tlb() for -* performance reasons */ -return i; -} -EXPORT_SYMBOL_GPL (unmap_page_from_agp); -#endif -/* * Generic routines for handling agp_memory structures - * They use the basic page allocation routines to do the brunt of the work.
drivers/char/agp/intel-agp.c +13 -2
@@ -185,9 +185,17 @@ static void *i8xx_alloc_pages(void)if (page ==NULL )return NULL ; +#ifdef CONFIG_XEN +if (xen_create_contiguous_region ((unsigned long )page_address (page),2 ,32 )) { +__free_pages (page,2 ); +return NULL ; + } +#endif +if (change_page_attr (page,4 ,PAGE_KERNEL_NOCACHE ) <0 ) { +change_page_attr (page,4 ,PAGE_KERNEL );global_flush_tlb (); -__free_page (page); +__free_pages (page,2 );return NULL ; }global_flush_tlb ();
@@ -207,9 +215,12 @@ static void i8xx_destroy_pages(void *add page =virt_to_page (addr);change_page_attr (page,4 ,PAGE_KERNEL );global_flush_tlb (); +#ifdef CONFIG_XEN +xen_destroy_contiguous_region ((unsigned long )page_address (page),2 ); +#endif put_page (page);unlock_page (page); -free_pages ((unsigned long )addr,2 ); +__free_pages (page,2 );atomic_dec (&agp_bridge->current_memory_agp); }
include/asm-i386/agp.h +4 -2
@@ -12,8 +12,10 @@* data corruption on some CPUs. */ -int map_page_into_agp (struct page *page); -int unmap_page_from_agp (struct page *page); +/* Caller's responsibility to call global_flush_tlb() for +* performance reasons */ +#define map_page_into_agp (page) change_page_attr(page, 1, PAGE_KERNEL_NOCACHE) +#define unmap_page_from_agp (page) change_page_attr(page, 1, PAGE_KERNEL)#define flush_agp_mappings () global_flush_tlb()/* Could use CLFLUSH here if the cpu supports it. But then it would
include/asm-i386/mach-xen/asm/agp.h +9 -2
@@ -13,8 +13,15 @@* data corruption on some CPUs. */ -int map_page_into_agp (struct page *page); -int unmap_page_from_agp (struct page *page); +/* Caller's responsibility to call global_flush_tlb() for +* performance reasons */ +#define map_page_into_agp (page) ( \ + xen_create_contiguous_region((unsigned long)page_address(page), 0, 32) \ + ?: change_page_attr(page, 1, PAGE_KERNEL_NOCACHE)) +#define unmap_page_from_agp (page) ( \ + xen_destroy_contiguous_region((unsigned long)page_address(page), 0), \ +/* only a fallback: xen_destroy_contiguous_region uses PAGE_KERNEL */ \ + change_page_attr(page, 1, PAGE_KERNEL))#define flush_agp_mappings () global_flush_tlb()/* Could use CLFLUSH here if the cpu supports it. But then it would
include/asm-x86_64/agp.h +4 -2
@@ -10,8 +10,10 @@* with different cachability attributes for the same page. */ -int map_page_into_agp (struct page *page); -int unmap_page_from_agp (struct page *page); +/* Caller's responsibility to call global_flush_tlb() for +* performance reasons */ +#define map_page_into_agp (page) change_page_attr(page, 1, PAGE_KERNEL_NOCACHE) +#define unmap_page_from_agp (page) change_page_attr(page, 1, PAGE_KERNEL)#define flush_agp_mappings () global_flush_tlb()/* Could use CLFLUSH here if the cpu supports it. But then it would
include/asm-x86_64/mach-xen/asm/agp.h +7 -2
@@ -11,8 +11,13 @@* with different cachability attributes for the same page. */ -int map_page_into_agp (struct page *page); -int unmap_page_from_agp (struct page *page); +#define map_page_into_agp (page) ( \ + xen_create_contiguous_region((unsigned long)page_address(page), 0, 32) \ + ?: change_page_attr(page, 1, PAGE_KERNEL_NOCACHE)) +#define unmap_page_from_agp (page) ( \ + xen_destroy_contiguous_region((unsigned long)page_address(page), 0), \ +/* only a fallback: xen_destroy_contiguous_region uses PAGE_KERNEL */ \ + change_page_attr(page, 1, PAGE_KERNEL))#define flush_agp_mappings () global_flush_tlb()/* Could use CLFLUSH here if the cpu supports it. But then it would