#include <xen/grant_table.h>
#include <xen/page.h>
#include <xen/xen-ops.h>
-#include <xen/swiotlb.h>
#include <asm/iommu.h>
#include <asm/swiotlb.h>
} while (0)
-static int max_dma_bits = 32;
-
-void xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs)
-{
- 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;
-
- i = 0;
- do {
- int slabs = min(nslabs - i, (unsigned long)IO_TLB_SEGSIZE);
-
- do {
- rc = xen_create_contiguous_region(
- (unsigned long)buf + (i << IO_TLB_SHIFT),
- get_order(slabs << IO_TLB_SHIFT),
- dma_bits);
- } while (rc && dma_bits++ < max_dma_bits);
- if (rc)
- panic(KERN_ERR "xen_create_contiguous_region failed\n");
-
- i += slabs;
- } while(i < nslabs);
-}
-
-int xen_wants_swiotlb(void)
-{
- return xen_initial_domain();
-}
-
dma_addr_t xen_phys_to_bus(phys_addr_t paddr)
{
return phys_to_machine(XPADDR(paddr)).maddr;
.is_phys = 0,
};
-static struct dma_map_ops xen_swiotlb_dma_ops = {
- .dma_supported = swiotlb_dma_supported,
-
- .alloc_coherent = xen_alloc_coherent,
- .free_coherent = xen_free_coherent,
-
- .map_page = swiotlb_map_page,
- .unmap_page = swiotlb_unmap_page,
-
- .map_sg = swiotlb_map_sg_attrs,
- .unmap_sg = swiotlb_unmap_sg_attrs,
-
- .mapping_error = swiotlb_dma_mapping_error,
-
- .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
- .sync_single_for_device = swiotlb_sync_single_for_device,
- .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
- .sync_single_range_for_device = swiotlb_sync_single_range_for_device,
- .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
- .sync_sg_for_device = swiotlb_sync_sg_for_device,
-
- .is_phys = 0,
-};
-
void __init xen_iommu_init(void)
{
if (!xen_pv_domain())
force_iommu = 0;
dma_ops = &xen_dma_ops;
-
- if (swiotlb) {
- printk(KERN_INFO "Xen: Enabling DMA fallback to swiotlb\n");
- dma_ops = &xen_swiotlb_dma_ops;
- }
}