diff options
Diffstat (limited to 'arch/x86/kernel/pci-dma.c')
-rw-r--r-- | arch/x86/kernel/pci-dma.c | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c index dc00a1331ace..cbecb05551bb 100644 --- a/arch/x86/kernel/pci-dma.c +++ b/arch/x86/kernel/pci-dma.c | |||
@@ -5,11 +5,11 @@ | |||
5 | 5 | ||
6 | #include <asm/proto.h> | 6 | #include <asm/proto.h> |
7 | #include <asm/dma.h> | 7 | #include <asm/dma.h> |
8 | #include <asm/gart.h> | 8 | #include <asm/iommu.h> |
9 | #include <asm/calgary.h> | 9 | #include <asm/calgary.h> |
10 | #include <asm/amd_iommu.h> | ||
10 | 11 | ||
11 | int forbid_dac __read_mostly; | 12 | static int forbid_dac __read_mostly; |
12 | EXPORT_SYMBOL(forbid_dac); | ||
13 | 13 | ||
14 | const struct dma_mapping_ops *dma_ops; | 14 | const struct dma_mapping_ops *dma_ops; |
15 | EXPORT_SYMBOL(dma_ops); | 15 | EXPORT_SYMBOL(dma_ops); |
@@ -74,13 +74,17 @@ early_param("dma32_size", parse_dma32_size_opt); | |||
74 | void __init dma32_reserve_bootmem(void) | 74 | void __init dma32_reserve_bootmem(void) |
75 | { | 75 | { |
76 | unsigned long size, align; | 76 | unsigned long size, align; |
77 | if (end_pfn <= MAX_DMA32_PFN) | 77 | if (max_pfn <= MAX_DMA32_PFN) |
78 | return; | 78 | return; |
79 | 79 | ||
80 | /* | ||
81 | * check aperture_64.c allocate_aperture() for reason about | ||
82 | * using 512M as goal | ||
83 | */ | ||
80 | align = 64ULL<<20; | 84 | align = 64ULL<<20; |
81 | size = round_up(dma32_bootmem_size, align); | 85 | size = round_up(dma32_bootmem_size, align); |
82 | dma32_bootmem_ptr = __alloc_bootmem_nopanic(size, align, | 86 | dma32_bootmem_ptr = __alloc_bootmem_nopanic(size, align, |
83 | __pa(MAX_DMA_ADDRESS)); | 87 | 512ULL<<20); |
84 | if (dma32_bootmem_ptr) | 88 | if (dma32_bootmem_ptr) |
85 | dma32_bootmem_size = size; | 89 | dma32_bootmem_size = size; |
86 | else | 90 | else |
@@ -88,17 +92,14 @@ void __init dma32_reserve_bootmem(void) | |||
88 | } | 92 | } |
89 | static void __init dma32_free_bootmem(void) | 93 | static void __init dma32_free_bootmem(void) |
90 | { | 94 | { |
91 | int node; | ||
92 | 95 | ||
93 | if (end_pfn <= MAX_DMA32_PFN) | 96 | if (max_pfn <= MAX_DMA32_PFN) |
94 | return; | 97 | return; |
95 | 98 | ||
96 | if (!dma32_bootmem_ptr) | 99 | if (!dma32_bootmem_ptr) |
97 | return; | 100 | return; |
98 | 101 | ||
99 | for_each_online_node(node) | 102 | free_bootmem(__pa(dma32_bootmem_ptr), dma32_bootmem_size); |
100 | free_bootmem_node(NODE_DATA(node), __pa(dma32_bootmem_ptr), | ||
101 | dma32_bootmem_size); | ||
102 | 103 | ||
103 | dma32_bootmem_ptr = NULL; | 104 | dma32_bootmem_ptr = NULL; |
104 | dma32_bootmem_size = 0; | 105 | dma32_bootmem_size = 0; |
@@ -112,19 +113,15 @@ void __init pci_iommu_alloc(void) | |||
112 | * The order of these functions is important for | 113 | * The order of these functions is important for |
113 | * fall-back/fail-over reasons | 114 | * fall-back/fail-over reasons |
114 | */ | 115 | */ |
115 | #ifdef CONFIG_GART_IOMMU | ||
116 | gart_iommu_hole_init(); | 116 | gart_iommu_hole_init(); |
117 | #endif | ||
118 | 117 | ||
119 | #ifdef CONFIG_CALGARY_IOMMU | ||
120 | detect_calgary(); | 118 | detect_calgary(); |
121 | #endif | ||
122 | 119 | ||
123 | detect_intel_iommu(); | 120 | detect_intel_iommu(); |
124 | 121 | ||
125 | #ifdef CONFIG_SWIOTLB | 122 | amd_iommu_detect(); |
123 | |||
126 | pci_swiotlb_init(); | 124 | pci_swiotlb_init(); |
127 | #endif | ||
128 | } | 125 | } |
129 | #endif | 126 | #endif |
130 | 127 | ||
@@ -180,9 +177,7 @@ static __init int iommu_setup(char *p) | |||
180 | swiotlb = 1; | 177 | swiotlb = 1; |
181 | #endif | 178 | #endif |
182 | 179 | ||
183 | #ifdef CONFIG_GART_IOMMU | ||
184 | gart_parse_options(p); | 180 | gart_parse_options(p); |
185 | #endif | ||
186 | 181 | ||
187 | #ifdef CONFIG_CALGARY_IOMMU | 182 | #ifdef CONFIG_CALGARY_IOMMU |
188 | if (!strncmp(p, "calgary", 7)) | 183 | if (!strncmp(p, "calgary", 7)) |
@@ -319,8 +314,7 @@ int dma_supported(struct device *dev, u64 mask) | |||
319 | { | 314 | { |
320 | #ifdef CONFIG_PCI | 315 | #ifdef CONFIG_PCI |
321 | if (mask > 0xffffffff && forbid_dac > 0) { | 316 | if (mask > 0xffffffff && forbid_dac > 0) { |
322 | printk(KERN_INFO "PCI: Disallowing DAC for device %s\n", | 317 | dev_info(dev, "PCI: Disallowing DAC for device\n"); |
323 | dev->bus_id); | ||
324 | return 0; | 318 | return 0; |
325 | } | 319 | } |
326 | #endif | 320 | #endif |
@@ -347,8 +341,7 @@ int dma_supported(struct device *dev, u64 mask) | |||
347 | type. Normally this doesn't make any difference, but gives | 341 | type. Normally this doesn't make any difference, but gives |
348 | more gentle handling of IOMMU overflow. */ | 342 | more gentle handling of IOMMU overflow. */ |
349 | if (iommu_sac_force && (mask >= DMA_40BIT_MASK)) { | 343 | if (iommu_sac_force && (mask >= DMA_40BIT_MASK)) { |
350 | printk(KERN_INFO "%s: Force SAC with mask %Lx\n", | 344 | dev_info(dev, "Force SAC with mask %Lx\n", mask); |
351 | dev->bus_id, mask); | ||
352 | return 0; | 345 | return 0; |
353 | } | 346 | } |
354 | 347 | ||
@@ -357,7 +350,7 @@ int dma_supported(struct device *dev, u64 mask) | |||
357 | EXPORT_SYMBOL(dma_supported); | 350 | EXPORT_SYMBOL(dma_supported); |
358 | 351 | ||
359 | /* Allocate DMA memory on node near device */ | 352 | /* Allocate DMA memory on node near device */ |
360 | noinline struct page * | 353 | static noinline struct page * |
361 | dma_alloc_pages(struct device *dev, gfp_t gfp, unsigned order) | 354 | dma_alloc_pages(struct device *dev, gfp_t gfp, unsigned order) |
362 | { | 355 | { |
363 | int node; | 356 | int node; |
@@ -496,15 +489,13 @@ EXPORT_SYMBOL(dma_free_coherent); | |||
496 | 489 | ||
497 | static int __init pci_iommu_init(void) | 490 | static int __init pci_iommu_init(void) |
498 | { | 491 | { |
499 | #ifdef CONFIG_CALGARY_IOMMU | ||
500 | calgary_iommu_init(); | 492 | calgary_iommu_init(); |
501 | #endif | ||
502 | 493 | ||
503 | intel_iommu_init(); | 494 | intel_iommu_init(); |
504 | 495 | ||
505 | #ifdef CONFIG_GART_IOMMU | 496 | amd_iommu_init(); |
497 | |||
506 | gart_iommu_init(); | 498 | gart_iommu_init(); |
507 | #endif | ||
508 | 499 | ||
509 | no_iommu_init(); | 500 | no_iommu_init(); |
510 | return 0; | 501 | return 0; |