aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/pci-dma.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kernel/pci-dma.c')
-rw-r--r--arch/x86/kernel/pci-dma.c55
1 files changed, 26 insertions, 29 deletions
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index a6e804d16c35..4b7e3d8b01dd 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -2,6 +2,7 @@
2#include <linux/dma-debug.h> 2#include <linux/dma-debug.h>
3#include <linux/dmar.h> 3#include <linux/dmar.h>
4#include <linux/bootmem.h> 4#include <linux/bootmem.h>
5#include <linux/gfp.h>
5#include <linux/pci.h> 6#include <linux/pci.h>
6#include <linux/kmemleak.h> 7#include <linux/kmemleak.h>
7 8
@@ -11,10 +12,11 @@
11#include <asm/gart.h> 12#include <asm/gart.h>
12#include <asm/calgary.h> 13#include <asm/calgary.h>
13#include <asm/amd_iommu.h> 14#include <asm/amd_iommu.h>
15#include <asm/x86_init.h>
14 16
15static int forbid_dac __read_mostly; 17static int forbid_dac __read_mostly;
16 18
17struct dma_map_ops *dma_ops; 19struct dma_map_ops *dma_ops = &nommu_dma_ops;
18EXPORT_SYMBOL(dma_ops); 20EXPORT_SYMBOL(dma_ops);
19 21
20static int iommu_sac_force __read_mostly; 22static int iommu_sac_force __read_mostly;
@@ -37,14 +39,11 @@ int iommu_detected __read_mostly = 0;
37 * This variable becomes 1 if iommu=pt is passed on the kernel command line. 39 * This variable becomes 1 if iommu=pt is passed on the kernel command line.
38 * If this variable is 1, IOMMU implementations do no DMA translation for 40 * If this variable is 1, IOMMU implementations do no DMA translation for
39 * devices and allow every device to access to whole physical memory. This is 41 * devices and allow every device to access to whole physical memory. This is
40 * useful if a user want to use an IOMMU only for KVM device assignment to 42 * useful if a user wants to use an IOMMU only for KVM device assignment to
41 * guests and not for driver dma translation. 43 * guests and not for driver dma translation.
42 */ 44 */
43int iommu_pass_through __read_mostly; 45int iommu_pass_through __read_mostly;
44 46
45dma_addr_t bad_dma_address __read_mostly = 0;
46EXPORT_SYMBOL(bad_dma_address);
47
48/* Dummy device used for NULL arguments (normally ISA). */ 47/* Dummy device used for NULL arguments (normally ISA). */
49struct device x86_dma_fallback_dev = { 48struct device x86_dma_fallback_dev = {
50 .init_name = "fallback device", 49 .init_name = "fallback device",
@@ -67,7 +66,7 @@ int dma_set_mask(struct device *dev, u64 mask)
67} 66}
68EXPORT_SYMBOL(dma_set_mask); 67EXPORT_SYMBOL(dma_set_mask);
69 68
70#ifdef CONFIG_X86_64 69#if defined(CONFIG_X86_64) && !defined(CONFIG_NUMA)
71static __initdata void *dma32_bootmem_ptr; 70static __initdata void *dma32_bootmem_ptr;
72static unsigned long dma32_bootmem_size __initdata = (128ULL<<20); 71static unsigned long dma32_bootmem_size __initdata = (128ULL<<20);
73 72
@@ -118,27 +117,33 @@ static void __init dma32_free_bootmem(void)
118 dma32_bootmem_ptr = NULL; 117 dma32_bootmem_ptr = NULL;
119 dma32_bootmem_size = 0; 118 dma32_bootmem_size = 0;
120} 119}
120#else
121void __init dma32_reserve_bootmem(void)
122{
123}
124static void __init dma32_free_bootmem(void)
125{
126}
127
121#endif 128#endif
122 129
123void __init pci_iommu_alloc(void) 130void __init pci_iommu_alloc(void)
124{ 131{
125#ifdef CONFIG_X86_64
126 /* free the range so iommu could get some range less than 4G */ 132 /* free the range so iommu could get some range less than 4G */
127 dma32_free_bootmem(); 133 dma32_free_bootmem();
128#endif
129 134
130 /* 135 if (pci_swiotlb_detect())
131 * The order of these functions is important for 136 goto out;
132 * fall-back/fail-over reasons 137
133 */
134 gart_iommu_hole_init(); 138 gart_iommu_hole_init();
135 139
136 detect_calgary(); 140 detect_calgary();
137 141
138 detect_intel_iommu(); 142 detect_intel_iommu();
139 143
144 /* needs to be called after gart_iommu_hole_init */
140 amd_iommu_detect(); 145 amd_iommu_detect();
141 146out:
142 pci_swiotlb_init(); 147 pci_swiotlb_init();
143} 148}
144 149
@@ -214,7 +219,7 @@ static __init int iommu_setup(char *p)
214 if (!strncmp(p, "allowdac", 8)) 219 if (!strncmp(p, "allowdac", 8))
215 forbid_dac = 0; 220 forbid_dac = 0;
216 if (!strncmp(p, "nodac", 5)) 221 if (!strncmp(p, "nodac", 5))
217 forbid_dac = -1; 222 forbid_dac = 1;
218 if (!strncmp(p, "usedac", 6)) { 223 if (!strncmp(p, "usedac", 6)) {
219 forbid_dac = -1; 224 forbid_dac = -1;
220 return 1; 225 return 1;
@@ -289,25 +294,17 @@ static int __init pci_iommu_init(void)
289#ifdef CONFIG_PCI 294#ifdef CONFIG_PCI
290 dma_debug_add_bus(&pci_bus_type); 295 dma_debug_add_bus(&pci_bus_type);
291#endif 296#endif
297 x86_init.iommu.iommu_init();
292 298
293 calgary_iommu_init(); 299 if (swiotlb) {
294 300 printk(KERN_INFO "PCI-DMA: "
295 intel_iommu_init(); 301 "Using software bounce buffering for IO (SWIOTLB)\n");
296 302 swiotlb_print_info();
297 amd_iommu_init(); 303 } else
304 swiotlb_free();
298 305
299 gart_iommu_init();
300
301 no_iommu_init();
302 return 0; 306 return 0;
303} 307}
304
305void pci_iommu_shutdown(void)
306{
307 gart_iommu_shutdown();
308
309 amd_iommu_shutdown();
310}
311/* Must execute after PCI subsystem */ 308/* Must execute after PCI subsystem */
312rootfs_initcall(pci_iommu_init); 309rootfs_initcall(pci_iommu_init);
313 310