1 #include <linux/dma-mapping.h>
2 #include <linux/dmar.h>
3 #include <linux/bootmem.h>
9 #include <asm/calgary.h>
11 int forbid_dac __read_mostly;
12 EXPORT_SYMBOL(forbid_dac);
14 const struct dma_mapping_ops *dma_ops;
15 EXPORT_SYMBOL(dma_ops);
17 #ifdef CONFIG_IOMMU_DEBUG
18 int panic_on_overflow __read_mostly = 1;
19 int force_iommu __read_mostly = 1;
21 int panic_on_overflow __read_mostly = 0;
22 int force_iommu __read_mostly = 0;
25 int dma_set_mask(struct device *dev, u64 mask)
27 if (!dev->dma_mask || !dma_supported(dev, mask))
30 *dev->dma_mask = mask;
34 EXPORT_SYMBOL(dma_set_mask);
37 static __initdata void *dma32_bootmem_ptr;
38 static unsigned long dma32_bootmem_size __initdata = (128ULL<<20);
40 static int __init parse_dma32_size_opt(char *p)
44 dma32_bootmem_size = memparse(p, &p);
47 early_param("dma32_size", parse_dma32_size_opt);
49 void __init dma32_reserve_bootmem(void)
51 unsigned long size, align;
52 if (end_pfn <= MAX_DMA32_PFN)
56 size = round_up(dma32_bootmem_size, align);
57 dma32_bootmem_ptr = __alloc_bootmem_nopanic(size, align,
58 __pa(MAX_DMA_ADDRESS));
59 if (dma32_bootmem_ptr)
60 dma32_bootmem_size = size;
62 dma32_bootmem_size = 0;
64 static void __init dma32_free_bootmem(void)
68 if (end_pfn <= MAX_DMA32_PFN)
71 if (!dma32_bootmem_ptr)
74 for_each_online_node(node)
75 free_bootmem_node(NODE_DATA(node), __pa(dma32_bootmem_ptr),
78 dma32_bootmem_ptr = NULL;
79 dma32_bootmem_size = 0;
82 void __init pci_iommu_alloc(void)
84 /* free the range so iommu could get some range less than 4G */
87 * The order of these functions is important for
88 * fall-back/fail-over reasons
90 #ifdef CONFIG_GART_IOMMU
91 gart_iommu_hole_init();
94 #ifdef CONFIG_CALGARY_IOMMU
100 #ifdef CONFIG_SWIOTLB
106 static int __init pci_iommu_init(void)
108 #ifdef CONFIG_CALGARY_IOMMU
109 calgary_iommu_init();
114 #ifdef CONFIG_GART_IOMMU
122 void pci_iommu_shutdown(void)
124 gart_iommu_shutdown();
126 /* Must execute after PCI subsystem */
127 fs_initcall(pci_iommu_init);
130 /* Many VIA bridges seem to corrupt data for DAC. Disable it here */
132 static __devinit void via_no_dac(struct pci_dev *dev)
134 if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI && forbid_dac == 0) {
135 printk(KERN_INFO "PCI: VIA PCI bridge detected."
140 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_ANY_ID, via_no_dac);