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

[Xen-devel] Re: [PATCH 04 of 38] swiotlb: move some definitions to header



On Mon, 2008-11-17 at 12:48 +0900, FUJITA Tomonori wrote:
> Why do we need to export IO_TLB_SEGSIZE and IO_TLB_SHIFT to everyone
> in include/linux?

A subsequent Xen patch needs to make use of them, although I can't see
it in the patchset Jeremy posted so here it is (not fully baked yet)

Subject: xen swiotlb: fixup swiotlb is chunks smaller than MAX_CONTIG_ORDER

From: Ian Campbell <ian.campbell@xxxxxxxxxx>

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
---
 arch/x86/kernel/pci-swiotlb_64.c |    7 +------
 drivers/pci/xen-iommu.c          |   30 ++++++++++++++++++++----------
 2 files changed, 21 insertions(+), 16 deletions(-)

===================================================================
--- a/arch/x86/kernel/pci-swiotlb_64.c
+++ b/arch/x86/kernel/pci-swiotlb_64.c
@@ -28,12 +28,7 @@
 
 void *swiotlb_alloc(unsigned order, unsigned long nslabs)
 {
-       void *ret = (void *)__get_free_pages(GFP_DMA | __GFP_NOWARN, order);
-
-       if (ret && xen_pv_domain())
-               xen_swiotlb_fixup(ret, 1u << order, nslabs);
-
-       return ret;
+       BUG();
 }
 
 static dma_addr_t
===================================================================
--- a/drivers/pci/xen-iommu.c
+++ b/drivers/pci/xen-iommu.c
@@ -6,6 +6,7 @@
 #include <linux/version.h>
 #include <linux/scatterlist.h>
 #include <linux/bio.h>
+#include <linux/swiotlb.h>
 #include <linux/io.h>
 #include <linux/bug.h>
 
@@ -43,19 +44,27 @@
        unsigned long   *bitmap;
 };
 
+static int max_dma_bits = 32;
+
 void xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs)
 {
-       unsigned order = get_order(size);
+       int i, rc;
+       int dma_bits;
 
-       printk(KERN_DEBUG "xen_swiotlb_fixup: buf=%p size=%zu order=%u\n",
-               buf, size, order);
+       printk(KERN_DEBUG "xen_swiotlb_fixup: buf=%p size=%zu\n",
+               buf, size);
 
-       if (WARN_ON(size != (PAGE_SIZE << order)))
-               return;
-
-       if (xen_create_contiguous_region((unsigned long)buf,
-                                        order, 0xffffffff))
-               printk(KERN_ERR "xen_create_contiguous_region failed\n");
+       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,
@@ -117,7 +126,8 @@
        if (check_pages_physically_contiguous(pfn, offset, size))
                return 0;
 
-       printk("range_straddles_page_boundary: p=%Lx size=%d pfn=%lx\n",
+       printk(KERN_WARNING "range_straddles_page_boundary: "
+              "p=%Lx size=%zd pfn=%lx\n",
                p, size, pfn);
        return 1;
 }



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


 


Rackspace

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