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 02/10] xen swiotlb: fixup swiotlb is chunks smaller t

To: Ingo Molnar <mingo@xxxxxxx>
Subject: [Xen-devel] [PATCH 02/10] xen swiotlb: fixup swiotlb is chunks smaller than MAX_CONTIG_ORDER
From: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Date: Tue, 12 May 2009 14:50:43 -0700
Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, Ian Campbell <ian.campbell@xxxxxxxxxx>, Joerg Roedel <joerg.roedel@xxxxxxx>, the arch/x86 maintainers <x86@xxxxxxxxxx>, Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>, FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx>, Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>, Matthew Wilcox <willy@xxxxxxxxxxxxxxx>
Delivery-date: Tue, 12 May 2009 16:29:57 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1242165051-6636-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: <1242165051-6636-1-git-send-email-jeremy@xxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
From: Ian Campbell <ian.campbell@xxxxxxxxxx>

Don't attempt to make larger memory ranges than Xen can cope with
contiguous.

[ Impact: bugfix ]
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
---
 drivers/pci/xen-iommu.c |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/xen-iommu.c b/drivers/pci/xen-iommu.c
index 8c034b8..ee7b9fb 100644
--- a/drivers/pci/xen-iommu.c
+++ b/drivers/pci/xen-iommu.c
@@ -5,6 +5,7 @@
 #include <linux/module.h>
 #include <linux/version.h>
 #include <linux/scatterlist.h>
+#include <linux/swiotlb.h>
 #include <linux/io.h>
 #include <linux/bug.h>
 
@@ -36,20 +37,29 @@ do {                                                        
\
 } while (0)
 
 
+static int max_dma_bits = 32;
+
 void xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs)
 {
-       unsigned order = get_order(size);
-
-       printk(KERN_DEBUG "xen_swiotlb_fixup: buf=%p size=%zu order=%u\n",
-               buf, size, order);
-
-       if (WARN_ON(size != (PAGE_SIZE << order)))
-               return;
-
-       if (xen_create_contiguous_region((unsigned long)buf,
-                                        order, DMA_BIT_MASK(32)))
-               printk(KERN_ERR "xen_create_contiguous_region failed\n");
+       int i, rc;
+       int dma_bits;
+
+       printk(KERN_DEBUG "xen_swiotlb_fixup: buf=%p size=%zu\n",
+               buf, size);
+
+       dma_bits = get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT) + PAGE_SHIFT;
+       for (i = 0; i < nslabs; i += IO_TLB_SEGSIZE) {
+               do {
+                       rc = xen_create_contiguous_region(
+                               (unsigned long)buf + (i << IO_TLB_SHIFT),
+                               get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT),
+                               dma_bits);
+               } while (rc && dma_bits++ < max_dma_bits);
+               if (rc)
+                       panic(KERN_ERR "xen_create_contiguous_region failed\n");
+       }
 }
+
 static inline int address_needs_mapping(struct device *hwdev,
                                                dma_addr_t addr)
 {
-- 
1.6.0.6


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