[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [linux-2.6.18-xen] linux: fix agp address handling, namely intel-agp



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1182429682 -3600
# Node ID 02a46885bd90a4d936338c135023b511318c7aa2
# Parent  c8c9bc0b7e29e804c09d4375a0e655cda826a9e4
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.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 drivers/char/agp/generic.c            |   22 ----------------------
 drivers/char/agp/intel-agp.c          |   15 +++++++++++++--
 include/asm-i386/agp.h                |    6 ++++--
 include/asm-i386/mach-xen/asm/agp.h   |   11 +++++++++--
 include/asm-x86_64/agp.h              |    6 ++++--
 include/asm-x86_64/mach-xen/asm/agp.h |    9 +++++++--
 6 files changed, 37 insertions(+), 32 deletions(-)

diff -r c8c9bc0b7e29 -r 02a46885bd90 drivers/char/agp/generic.c
--- a/drivers/char/agp/generic.c        Thu Jun 21 13:39:05 2007 +0100
+++ b/drivers/char/agp/generic.c        Thu Jun 21 13:41:22 2007 +0100
@@ -50,28 +50,6 @@ int agp_memory_reserved;
  * nice to do this some other way instead of needing this export.
  */
 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 -
diff -r c8c9bc0b7e29 -r 02a46885bd90 drivers/char/agp/intel-agp.c
--- a/drivers/char/agp/intel-agp.c      Thu Jun 21 13:39:05 2007 +0100
+++ b/drivers/char/agp/intel-agp.c      Thu Jun 21 13:41:22 2007 +0100
@@ -164,9 +164,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();
@@ -186,9 +194,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);
 }
 
diff -r c8c9bc0b7e29 -r 02a46885bd90 include/asm-i386/agp.h
--- a/include/asm-i386/agp.h    Thu Jun 21 13:39:05 2007 +0100
+++ b/include/asm-i386/agp.h    Thu Jun 21 13:41:22 2007 +0100
@@ -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
diff -r c8c9bc0b7e29 -r 02a46885bd90 include/asm-i386/mach-xen/asm/agp.h
--- a/include/asm-i386/mach-xen/asm/agp.h       Thu Jun 21 13:39:05 2007 +0100
+++ b/include/asm-i386/mach-xen/asm/agp.h       Thu Jun 21 13:41:22 2007 +0100
@@ -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
diff -r c8c9bc0b7e29 -r 02a46885bd90 include/asm-x86_64/agp.h
--- a/include/asm-x86_64/agp.h  Thu Jun 21 13:39:05 2007 +0100
+++ b/include/asm-x86_64/agp.h  Thu Jun 21 13:41:22 2007 +0100
@@ -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
diff -r c8c9bc0b7e29 -r 02a46885bd90 include/asm-x86_64/mach-xen/asm/agp.h
--- a/include/asm-x86_64/mach-xen/asm/agp.h     Thu Jun 21 13:39:05 2007 +0100
+++ b/include/asm-x86_64/mach-xen/asm/agp.h     Thu Jun 21 13:41:22 2007 +0100
@@ -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

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.