1 // SPDX-License-Identifier: GPL-2.0
3 * Dynamic DMA mapping support.
6 #include <linux/types.h>
8 #include <linux/string.h>
10 #include <linux/module.h>
11 #include <linux/dmar.h>
12 #include <asm/iommu.h>
13 #include <asm/machvec.h>
14 #include <linux/dma-mapping.h>
15 #include <linux/kernel.h>
18 dma_addr_t bad_dma_address __read_mostly;
19 EXPORT_SYMBOL(bad_dma_address);
21 int no_iommu __read_mostly;
22 #ifdef CONFIG_IOMMU_DEBUG
23 int force_iommu __read_mostly = 1;
25 int force_iommu __read_mostly;
28 int iommu_pass_through;
30 extern struct dma_map_ops intel_dma_ops;
32 static int __init pci_iommu_init(void)
40 /* Must execute after PCI subsystem */
41 fs_initcall(pci_iommu_init);
43 void pci_iommu_shutdown(void)
54 void __init pci_iommu_alloc(void)
56 dma_ops = &intel_dma_ops;
58 intel_dma_ops.sync_single_for_cpu = machvec_dma_sync_single;
59 intel_dma_ops.sync_sg_for_cpu = machvec_dma_sync_sg;
60 intel_dma_ops.sync_single_for_device = machvec_dma_sync_single;
61 intel_dma_ops.sync_sg_for_device = machvec_dma_sync_sg;
64 * The order of these functions is important for
65 * fall-back/fail-over reasons
70 if (!iommu_detected) {
71 #ifdef CONFIG_IA64_GENERIC
72 printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.\n");
76 panic("Unable to find Intel IOMMU");
77 #endif /* CONFIG_IA64_GENERIC */
79 #endif /* CONFIG_SWIOTLB */