1 /* Glue code to lib/swiotlb-xen.c */
3 #include <linux/dma-mapping.h>
5 #include <xen/swiotlb-xen.h>
7 #include <asm/xen/hypervisor.h>
9 #include <asm/iommu_table.h>
11 #include <asm/xen/swiotlb-xen.h>
12 int xen_swiotlb __read_mostly
;
14 static struct dma_map_ops xen_swiotlb_dma_ops
= {
15 .mapping_error
= xen_swiotlb_dma_mapping_error
,
16 .alloc
= xen_swiotlb_alloc_coherent
,
17 .free
= xen_swiotlb_free_coherent
,
18 .sync_single_for_cpu
= xen_swiotlb_sync_single_for_cpu
,
19 .sync_single_for_device
= xen_swiotlb_sync_single_for_device
,
20 .sync_sg_for_cpu
= xen_swiotlb_sync_sg_for_cpu
,
21 .sync_sg_for_device
= xen_swiotlb_sync_sg_for_device
,
22 .map_sg
= xen_swiotlb_map_sg_attrs
,
23 .unmap_sg
= xen_swiotlb_unmap_sg_attrs
,
24 .map_page
= xen_swiotlb_map_page
,
25 .unmap_page
= xen_swiotlb_unmap_page
,
26 .dma_supported
= xen_swiotlb_dma_supported
,
30 * pci_xen_swiotlb_detect - set xen_swiotlb to 1 if necessary
32 * This returns non-zero if we are forced to use xen_swiotlb (by the boot
35 int __init
pci_xen_swiotlb_detect(void)
38 /* If running as PV guest, either iommu=soft, or swiotlb=force will
39 * activate this IOMMU. If running as PV privileged, activate it
42 if ((xen_initial_domain() || swiotlb
|| swiotlb_force
) &&
46 /* If we are running under Xen, we MUST disable the native SWIOTLB.
47 * Don't worry about swiotlb_force flag activating the native, as
48 * the 'swiotlb' flag is the only one turning it on. */
55 void __init
pci_xen_swiotlb_init(void)
59 dma_ops
= &xen_swiotlb_dma_ops
;
61 /* Make sure ACS will be enabled */
65 IOMMU_INIT_FINISH(pci_xen_swiotlb_detect
,