3c2884bef3d4a8b373470a490aa6e73ad3cc8d0c
[linux-2.6-microblaze.git] / arch / ia64 / kernel / pci-dma.c
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 dma_addr_t bad_dma_address __read_mostly;
19 EXPORT_SYMBOL(bad_dma_address);
20
21 int no_iommu __read_mostly;
22 #ifdef CONFIG_IOMMU_DEBUG
23 int force_iommu __read_mostly = 1;
24 #else
25 int force_iommu __read_mostly;
26 #endif
27
28 int iommu_pass_through;
29
30 extern struct dma_map_ops intel_dma_ops;
31
32 static int __init pci_iommu_init(void)
33 {
34         if (iommu_detected)
35                 intel_iommu_init();
36
37         return 0;
38 }
39
40 /* Must execute after PCI subsystem */
41 fs_initcall(pci_iommu_init);
42
43 void pci_iommu_shutdown(void)
44 {
45         return;
46 }
47
48 void __init
49 iommu_dma_init(void)
50 {
51         return;
52 }
53
54 void __init pci_iommu_alloc(void)
55 {
56         dma_ops = &intel_dma_ops;
57
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;
62
63         /*
64          * The order of these functions is important for
65          * fall-back/fail-over reasons
66          */
67         detect_intel_iommu();
68
69 #ifdef CONFIG_SWIOTLB
70         if (!iommu_detected) {
71 #ifdef CONFIG_IA64_GENERIC
72                 printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.\n");
73                 machvec_init("dig");
74                 swiotlb_dma_init();
75 #else
76                 panic("Unable to find Intel IOMMU");
77 #endif /* CONFIG_IA64_GENERIC */
78         }
79 #endif /* CONFIG_SWIOTLB */
80 }