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
*/
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);
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.
{
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;
+ }
+}