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] use dev DMA masks in dma_alloc_coherent

To: Keir.Fraser@xxxxxxxxxxxx
Subject: [Xen-devel] [Patch] use dev DMA masks in dma_alloc_coherent
From: "Siddha, Suresh B" <suresh.b.siddha@xxxxxxxxx>
Date: Thu, 18 Aug 2005 11:23:08 -0700
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Thu, 18 Aug 2005 18:21:24 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.2.5.1i
64bit devices (whose dma_mask and coherent_dma_mask are set to 64bits)
can use MEMZONE_DOM while creating contiguous_region for coherent
mappings.

Please apply the appended patch.

Signed-off-by: Suresh Siddha <suresh.b.siddha@xxxxxxxxx>

diff -r 84ee014ebd41 linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c       Wed Aug 17 
20:34:38 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c       Thu Aug 18 
11:06:42 2005
@@ -129,6 +129,7 @@
        struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
        unsigned int order = get_order(size);
        unsigned long vstart;
+       unsigned long dma_mask = 0;
        /* ignore region specifiers */
        gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
 
@@ -145,13 +146,18 @@
                        return NULL;
        }
 
-       if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
-               gfp |= GFP_DMA;
+       if (!dev)
+               dma_mask = 0xffffffff;
+       else
+               /* Kludge to make it bug-to-bug compatible with i386. i386
+                  uses the normal dma_mask for alloc_coherent. */
+               dma_mask = dev->coherent_dma_mask & *dev->dma_mask;
 
        vstart = __get_free_pages(gfp, order);
        ret = (void *)vstart;
 
        if (ret != NULL) {
+               order |= (dma_mask <= 0xffffffff) ? (32 << 8) : 0;
                xen_create_contiguous_region(vstart, order);
 
                memset(ret, 0, size);
diff -r 84ee014ebd41 linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c       Wed Aug 17 
20:34:38 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c       Thu Aug 18 
11:06:42 2005
@@ -131,7 +131,7 @@
 
        xen_create_contiguous_region(
                (unsigned long)io_tlb_start, 
-               get_order(io_tlb_nslabs * (1 << IO_TLB_SHIFT)));
+               get_order(io_tlb_nslabs * (1 << IO_TLB_SHIFT)) | (32 << 8));
 
        io_tlb_end = io_tlb_start + io_tlb_nslabs * (1 << IO_TLB_SHIFT);
 
diff -r 84ee014ebd41 linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c        Wed Aug 17 
20:34:38 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c        Thu Aug 18 
11:06:42 2005
@@ -294,7 +294,7 @@
 
     /* 2. Get a new contiguous memory extent. */
     BUG_ON(HYPERVISOR_dom_mem_op(
-              MEMOP_increase_reservation, &mfn, 1, order | (32<<8)) != 1);
+              MEMOP_increase_reservation, &mfn, 1, order) != 1);
 
     /* 3. Map the new extent in place of old pages. */
     for (i = 0; i < (1<<order); i++) {
diff -r 84ee014ebd41 linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c   Wed Aug 17 20:34:38 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c   Thu Aug 18 11:06:42 2005
@@ -277,7 +277,7 @@
 
 #ifdef CONFIG_X86_PAE
        /* this gives us a page below 4GB */
-       xen_create_contiguous_region((unsigned long)pgd, 0);
+       xen_create_contiguous_region((unsigned long)pgd, 0 | (32 << 8));
 #endif
 
        if (!HAVE_SHARED_KERNEL_PMD)

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [Patch] use dev DMA masks in dma_alloc_coherent, Siddha, Suresh B <=