WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 27/27] agp/intel: use dma_alloc_coherent for special

To: "H. Peter Anvin" <hpa@xxxxxxxxx>
Subject: [Xen-devel] [PATCH 27/27] agp/intel: use dma_alloc_coherent for special cursor memory
From: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Date: Fri, 13 Mar 2009 10:00:12 -0700
Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, David Airlie <airlied@xxxxxxxx>, the arch/x86 maintainers <x86@xxxxxxxxxx>, Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>, Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
Delivery-date: Fri, 13 Mar 2009 10:19:32 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1236963612-14287-1-git-send-email-jeremy@xxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1236963612-14287-1-git-send-email-jeremy@xxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
From: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>

Given that i810 wants special physically contiguous memory for its cursor,
allocate it with dma_alloc_coherent, which will give us memory with the
right properties.  This is particularly for Xen, which won't normally
give us physically contiuous memory.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
Cc: David Airlie <airlied@xxxxxxxx>
---
 drivers/char/agp/intel-agp.c |   26 +++++++++++---------------
 1 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 4373adb..8ba6808 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -244,33 +244,29 @@ static void intel_i810_agp_enable(struct agp_bridge_data 
*bridge, u32 mode)
 /* Exists to support ARGB cursors */
 static void *i8xx_alloc_pages(void)
 {
-       struct page *page;
-
-       page = alloc_pages(GFP_KERNEL | GFP_DMA32, 2);
-       if (page == NULL)
+       void *addr;
+       dma_addr_t _d;
+       
+       addr = dma_alloc_coherent(NULL, 4 * PAGE_SIZE, &_d, GFP_KERNEL);
+       if (addr == NULL)
                return NULL;
 
-       if (set_pages_uc(page, 4) < 0) {
-               set_pages_wb(page, 4);
-               __free_pages(page, 2);
+       if (set_memory_uc((unsigned long)addr, 4) < 0) {
+               set_memory_wb((unsigned long)addr, 4);
+               dma_free_coherent(NULL, 4 * PAGE_SIZE, addr, _d);
                return NULL;
        }
-       get_page(page);
        atomic_inc(&agp_bridge->current_memory_agp);
-       return page_address(page);
+       return addr;
 }
 
 static void i8xx_destroy_pages(void *addr)
 {
-       struct page *page;
-
        if (addr == NULL)
                return;
 
-       page = virt_to_page(addr);
-       set_pages_wb(page, 4);
-       put_page(page);
-       __free_pages(page, 2);
+       set_memory_wb((unsigned long)addr, 4);
+       dma_free_coherent(NULL, 4 * PAGE_SIZE, addr, virt_to_bus(addr));
        atomic_dec(&agp_bridge->current_memory_agp);
 }
 
-- 
1.6.0.6


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