]> xenbits.xensource.com Git - people/ssmith/netchannel2-pvops.git/commitdiff
xen swiotlb: allocate swiotlb in chunks smaller than MAX_CONTIG_ORDER
authorIan Campbell <ian.campbell@citrix.com>
Mon, 9 Feb 2009 20:05:47 +0000 (12:05 -0800)
committerJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Thu, 25 Jun 2009 23:33:40 +0000 (16:33 -0700)
Don't attempt to make larger memory ranges than Xen can cope with
contiguous, by allocating them in IO_TLB_SEGSIZE-sized chunks rather
than in one large piece.

[ Impact: ask Xen for contigious memory in IO_TLB_SEGSIZE chunks ]

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
drivers/pci/xen-iommu.c

index 8c034b8800626c03384173c65902b8e02e9413a7..ee7b9fb9122651fcf4187e81aca25b8d58ab7d29 100644 (file)
@@ -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)
 {