]> xenbits.xensource.com Git - people/ssmith/netchannel2-pvops.git/commitdiff
Provide two functions:xen_swiotlb_[init|init_alloc] and remove dupliate __setup function.
authorKonrad Rzeszutek Wilk <kliw@darnok.org>
Mon, 31 Aug 2009 19:32:10 +0000 (15:32 -0400)
committerJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Wed, 2 Sep 2009 18:23:03 +0000 (11:23 -0700)
The two functions are correspondingly used to detect whether
to utilize the Xen-SWIOTLB and if so allocate a 64MB SWIOTLB
(similar to what swiotlb_init does).

The __setup function is used to parse the 'swiotlb' arguments.
This is already done in lib/swiotlb.c.

Lastly, we setup a dma_map_ops struct with xen_swiotlb_* functions.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
arch/x86/include/asm/xen/swiotlb.h [new file with mode: 0644]
arch/x86/xen/pci-swiotlb.c

diff --git a/arch/x86/include/asm/xen/swiotlb.h b/arch/x86/include/asm/xen/swiotlb.h
new file mode 100644 (file)
index 0000000..81d8502
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef _ASM_X86_XEN_SWIOTLB_H
+#define _ASM_X86_XEN_SWIOTLB_H
+
+#ifdef CONFIG_PCI_XEN
+extern int xen_swiotlb_init(void);
+extern void xen_swiotlb_init_alloc(void);
+#else
+static inline int xen_swiotlb_init(void) { return -ENODEV; }
+static void xen_swiotlb_init_alloc(void) { }
+#endif
+
+#endif
index 51f913da2c854dd745419b57756bacf8a325fac9..8b41778efd75499bbab2a4532ae963f587ff0eca 100644 (file)
@@ -57,8 +57,6 @@ enum dma_sync_target {
        SYNC_FOR_DEVICE = 1,
 };
 
-int xen_swiotlb_force;
-
 /*
  * Used to do a quick range check in unmap_single and
  * sync_single_*, to see if the memory was in fact allocated by this
@@ -97,23 +95,6 @@ static phys_addr_t *xen_io_tlb_orig_addr;
  */
 static DEFINE_SPINLOCK(xen_io_tlb_lock);
 
-static int __init
-setup_xen_io_tlb_npages(char *str)
-{
-       if (isdigit(*str)) {
-               xen_io_tlb_nslabs = simple_strtoul(str, &str, 0);
-               /* avoid tail segment of size < IO_TLB_SEGSIZE */
-               xen_io_tlb_nslabs = ALIGN(xen_io_tlb_nslabs, IO_TLB_SEGSIZE);
-       }
-       if (*str == ',')
-               ++str;
-       if (!strcmp(str, "force"))
-               xen_swiotlb_force = 1;
-       return 1;
-}
-__setup("swiotlb=", setup_xen_io_tlb_npages);
-/* make xen_io_tlb_overflow tunable too? */
-
 void * __weak __init xen_swiotlb_alloc_boot(size_t size, unsigned long nslabs)
 {
        return alloc_bootmem_low_pages(size);
@@ -216,12 +197,6 @@ xen_swiotlb_init_with_default_size(size_t default_size)
        xen_swiotlb_print_info(bytes);
 }
 
-void __init
-xen_swiotlb_init(void)
-{
-       xen_swiotlb_init_with_default_size(64 * (1<<20));       /* default to 64MB */
-}
-
 /*
  * Systems with larger DMA zones (those that don't support ISA) can
  * initialize the swiotlb later using the slab allocator if needed.
@@ -915,3 +890,37 @@ xen_swiotlb_dma_supported(struct device *hwdev, u64 mask)
 {
        return xen_swiotlb_virt_to_bus(hwdev, xen_io_tlb_end - 1) <= mask;
 }
+
+static struct dma_map_ops xen_swiotlb_dma_ops = {
+       .mapping_error = xen_swiotlb_dma_mapping_error,
+       .alloc_coherent = xen_swiotlb_alloc_coherent,
+       .free_coherent = xen_swiotlb_free_coherent,
+       .sync_single_for_cpu = xen_swiotlb_sync_single_for_cpu,
+       .sync_single_for_device = xen_swiotlb_sync_single_for_device,
+       .sync_single_range_for_cpu = xen_swiotlb_sync_single_range_for_cpu,
+       .sync_single_range_for_device = xen_swiotlb_sync_single_range_for_device,
+       .sync_sg_for_cpu = xen_swiotlb_sync_sg_for_cpu,
+       .sync_sg_for_device = xen_swiotlb_sync_sg_for_device,
+       .map_sg = xen_swiotlb_map_sg_attrs,
+       .unmap_sg = xen_swiotlb_unmap_sg_attrs,
+       .map_page = xen_swiotlb_map_page,
+       .unmap_page = xen_swiotlb_unmap_page,
+       .dma_supported = NULL,
+};
+
+int __init xen_swiotlb_init(void)
+{
+       if (xen_pv_domain() && xen_initial_domain()) {
+               iommu_detected = 1;
+               return 0;
+       }
+       return -ENODEV;
+}
+void __init xen_swiotlb_init_alloc(void)
+{
+       if (xen_pv_domain() && xen_initial_domain()) {
+               printk(KERN_INFO "PCI-DMA: Using Xen software bounce buffering for IO (Xen-SWIOTLB)\n");
+               xen_swiotlb_init_with_default_size(64 * (1<<20));       /* default to 64MB */
+               dma_ops = &xen_swiotlb_dma_ops;
+       }
+}