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>
12 #include <asm/xen/swiotlb-xen.h>
14 #include <asm/iommu.h>
17 #include <linux/export.h>
19 int xen_swiotlb __read_mostly
;
22 * pci_xen_swiotlb_detect - set xen_swiotlb to 1 if necessary
24 * This returns non-zero if we are forced to use xen_swiotlb (by the boot
27 int __init
pci_xen_swiotlb_detect(void)
33 /* If running as PV guest, either iommu=soft, or swiotlb=force will
34 * activate this IOMMU. If running as PV privileged, activate it
37 if (xen_initial_domain() || swiotlb
|| swiotlb_force
== SWIOTLB_FORCE
)
40 /* If we are running under Xen, we MUST disable the native SWIOTLB.
41 * Don't worry about swiotlb_force flag activating the native, as
42 * the 'swiotlb' flag is the only one turning it on. */
46 /* pci_swiotlb_detect_4gb turns on native SWIOTLB if no_iommu == 0
47 * (so no iommu=X command line over-writes).
48 * Considering that PV guests do not want the *native SWIOTLB* but
49 * only Xen SWIOTLB it is not useful to us so set no_iommu=1 here.
51 if (max_pfn
> MAX_DMA32_PFN
)
57 void __init
pci_xen_swiotlb_init(void)
60 xen_swiotlb_init(1, true /* early */);
61 dma_ops
= &xen_swiotlb_dma_ops
;
64 /* Make sure ACS will be enabled */
70 int pci_xen_swiotlb_init_late(void)
77 rc
= xen_swiotlb_init(1, false /* late */);
81 dma_ops
= &xen_swiotlb_dma_ops
;
83 /* Make sure ACS will be enabled */
89 EXPORT_SYMBOL_GPL(pci_xen_swiotlb_init_late
);
91 IOMMU_INIT_FINISH(pci_xen_swiotlb_detect
,