1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Dynamic DMA mapping support. 4 */ 5 6 #include <linux/types.h> 7 #include <linux/mm.h> 8 #include <linux/string.h> 9 #include <linux/pci.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> 16 #include <asm/page.h> 17 18 int no_iommu __read_mostly; 19 #ifdef CONFIG_IOMMU_DEBUG 20 int force_iommu __read_mostly = 1; 21 #else 22 int force_iommu __read_mostly; 23 #endif 24 25 int iommu_pass_through; 26 27 static int __init pci_iommu_init(void) 28 { 29 if (iommu_detected) 30 intel_iommu_init(); 31 32 return 0; 33 } 34 35 /* Must execute after PCI subsystem */ 36 fs_initcall(pci_iommu_init); 37 38 void __init pci_iommu_alloc(void) 39 { 40 /* 41 * The order of these functions is important for 42 * fall-back/fail-over reasons 43 */ 44 detect_intel_iommu(); 45 46 #ifdef CONFIG_SWIOTLB 47 if (!iommu_detected) { 48 #ifdef CONFIG_IA64_GENERIC 49 printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.\n"); 50 machvec_init("dig"); 51 swiotlb_dma_init(); 52 #else 53 panic("Unable to find Intel IOMMU"); 54 #endif /* CONFIG_IA64_GENERIC */ 55 } 56 #endif /* CONFIG_SWIOTLB */ 57 } 58