Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Fenghua Yu | 62fdd76 | 2008-10-17 12:14:13 -0700 | [diff] [blame] | 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> |
Fenghua Yu | 62fdd76 | 2008-10-17 12:14:13 -0700 | [diff] [blame] | 15 | #include <linux/kernel.h> |
Fenghua Yu | 62fdd76 | 2008-10-17 12:14:13 -0700 | [diff] [blame] | 16 | #include <asm/page.h> |
Fenghua Yu | 62fdd76 | 2008-10-17 12:14:13 -0700 | [diff] [blame] | 17 | |
Fenghua Yu | 62fdd76 | 2008-10-17 12:14:13 -0700 | [diff] [blame] | 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 | |
Fenghua Yu | aed5d5f | 2009-04-30 17:57:11 -0700 | [diff] [blame] | 25 | int iommu_pass_through; |
| 26 | |
Fenghua Yu | 62fdd76 | 2008-10-17 12:14:13 -0700 | [diff] [blame] | 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 | |
FUJITA Tomonori | 160c1d8 | 2009-01-05 23:59:02 +0900 | [diff] [blame] | 38 | void __init pci_iommu_alloc(void) |
| 39 | { |
FUJITA Tomonori | 160c1d8 | 2009-01-05 23:59:02 +0900 | [diff] [blame] | 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 |
Christoph Hellwig | 4fac807 | 2017-12-24 13:57:08 +0100 | [diff] [blame] | 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 */ |
FUJITA Tomonori | 160c1d8 | 2009-01-05 23:59:02 +0900 | [diff] [blame] | 57 | } |