hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/x86/kernel/pci-dma.c
....@@ -1,9 +1,10 @@
11 // SPDX-License-Identifier: GPL-2.0
2
+#include <linux/dma-map-ops.h>
23 #include <linux/dma-direct.h>
3
-#include <linux/dma-debug.h>
4
+#include <linux/iommu.h>
45 #include <linux/dmar.h>
56 #include <linux/export.h>
6
-#include <linux/bootmem.h>
7
+#include <linux/memblock.h>
78 #include <linux/gfp.h>
89 #include <linux/pci.h>
910
....@@ -11,13 +12,12 @@
1112 #include <asm/dma.h>
1213 #include <asm/iommu.h>
1314 #include <asm/gart.h>
14
-#include <asm/calgary.h>
1515 #include <asm/x86_init.h>
1616 #include <asm/iommu_table.h>
1717
1818 static bool disable_dac_quirk __read_mostly;
1919
20
-const struct dma_map_ops *dma_ops = &dma_direct_ops;
20
+const struct dma_map_ops *dma_ops;
2121 EXPORT_SYMBOL(dma_ops);
2222
2323 #ifdef CONFIG_IOMMU_DEBUG
....@@ -34,30 +34,7 @@
3434 /* Set this to 1 if there is a HW IOMMU in the system */
3535 int iommu_detected __read_mostly = 0;
3636
37
-/*
38
- * This variable becomes 1 if iommu=pt is passed on the kernel command line.
39
- * If this variable is 1, IOMMU implementations do no DMA translation for
40
- * devices and allow every device to access to whole physical memory. This is
41
- * useful if a user wants to use an IOMMU only for KVM device assignment to
42
- * guests and not for driver dma translation.
43
- * It is also possible to disable by default in kernel config, and enable with
44
- * iommu=nopt at boot time.
45
- */
46
-#ifdef CONFIG_IOMMU_DEFAULT_PASSTHROUGH
47
-int iommu_pass_through __read_mostly = 1;
48
-#else
49
-int iommu_pass_through __read_mostly;
50
-#endif
51
-
5237 extern struct iommu_table_entry __iommu_table[], __iommu_table_end[];
53
-
54
-/* Dummy device used for NULL arguments (normally ISA). */
55
-struct device x86_dma_fallback_dev = {
56
- .init_name = "fallback device",
57
- .coherent_dma_mask = ISA_DMA_BIT_MASK,
58
- .dma_mask = &x86_dma_fallback_dev.coherent_dma_mask,
59
-};
60
-EXPORT_SYMBOL(x86_dma_fallback_dev);
6138
6239 void __init pci_iommu_alloc(void)
6340 {
....@@ -77,20 +54,8 @@
7754 }
7855 }
7956
80
-bool arch_dma_alloc_attrs(struct device **dev)
81
-{
82
- if (!*dev)
83
- *dev = &x86_dma_fallback_dev;
84
-
85
- if (!is_device_dma_capable(*dev))
86
- return false;
87
- return true;
88
-
89
-}
90
-EXPORT_SYMBOL(arch_dma_alloc_attrs);
91
-
9257 /*
93
- * See <Documentation/x86/x86_64/boot-options.txt> for the iommu kernel
58
+ * See <Documentation/x86/x86_64/boot-options.rst> for the iommu kernel
9459 * parameter documentation.
9560 */
9661 static __init int iommu_setup(char *p)
....@@ -140,16 +105,11 @@
140105 swiotlb = 1;
141106 #endif
142107 if (!strncmp(p, "pt", 2))
143
- iommu_pass_through = 1;
108
+ iommu_set_default_passthrough(true);
144109 if (!strncmp(p, "nopt", 4))
145
- iommu_pass_through = 0;
110
+ iommu_set_default_translated(true);
146111
147112 gart_parse_options(p);
148
-
149
-#ifdef CONFIG_CALGARY_IOMMU
150
- if (!strncmp(p, "calgary", 7))
151
- use_calgary = 1;
152
-#endif /* CONFIG_CALGARY_IOMMU */
153113
154114 p += strcspn(p, ",");
155115 if (*p == ',')
....@@ -180,7 +140,7 @@
180140
181141 static int via_no_dac_cb(struct pci_dev *pdev, void *data)
182142 {
183
- pdev->dev.bus_dma_mask = DMA_BIT_MASK(32);
143
+ pdev->dev.bus_dma_limit = DMA_BIT_MASK(32);
184144 return 0;
185145 }
186146