thinkpad-acpi: fix use of MODULE_AUTHOR
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / ia64 / kernel / pci-dma.c
blobd0ada067a4af52bd83fdac763b862d3b62e2ed13
1 /*
2 * Dynamic DMA mapping support.
3 */
5 #include <linux/types.h>
6 #include <linux/mm.h>
7 #include <linux/string.h>
8 #include <linux/pci.h>
9 #include <linux/module.h>
10 #include <linux/dmar.h>
11 #include <asm/iommu.h>
12 #include <asm/machvec.h>
13 #include <linux/dma-mapping.h>
15 #include <asm/system.h>
17 #ifdef CONFIG_DMAR
19 #include <linux/kernel.h>
21 #include <asm/page.h>
23 dma_addr_t bad_dma_address __read_mostly;
24 EXPORT_SYMBOL(bad_dma_address);
26 static int iommu_sac_force __read_mostly;
28 int no_iommu __read_mostly;
29 #ifdef CONFIG_IOMMU_DEBUG
30 int force_iommu __read_mostly = 1;
31 #else
32 int force_iommu __read_mostly;
33 #endif
35 /* Set this to 1 if there is a HW IOMMU in the system */
36 int iommu_detected __read_mostly;
38 /* Dummy device used for NULL arguments (normally ISA). Better would
39 be probably a smaller DMA mask, but this is bug-to-bug compatible
40 to i386. */
41 struct device fallback_dev = {
42 .init_name = "fallback device",
43 .coherent_dma_mask = DMA_32BIT_MASK,
44 .dma_mask = &fallback_dev.coherent_dma_mask,
47 void __init pci_iommu_alloc(void)
50 * The order of these functions is important for
51 * fall-back/fail-over reasons
53 detect_intel_iommu();
55 #ifdef CONFIG_SWIOTLB
56 pci_swiotlb_init();
57 #endif
60 static int __init pci_iommu_init(void)
62 if (iommu_detected)
63 intel_iommu_init();
65 return 0;
68 /* Must execute after PCI subsystem */
69 fs_initcall(pci_iommu_init);
71 void pci_iommu_shutdown(void)
73 return;
76 void __init
77 iommu_dma_init(void)
79 return;
82 struct dma_mapping_ops *dma_ops;
83 EXPORT_SYMBOL(dma_ops);
85 int iommu_dma_supported(struct device *dev, u64 mask)
87 struct dma_mapping_ops *ops = get_dma_ops(dev);
89 if (ops->dma_supported_op)
90 return ops->dma_supported_op(dev, mask);
92 /* Copied from i386. Doesn't make much sense, because it will
93 only work for pci_alloc_coherent.
94 The caller just has to use GFP_DMA in this case. */
95 if (mask < DMA_24BIT_MASK)
96 return 0;
98 /* Tell the device to use SAC when IOMMU force is on. This
99 allows the driver to use cheaper accesses in some cases.
101 Problem with this is that if we overflow the IOMMU area and
102 return DAC as fallback address the device may not handle it
103 correctly.
105 As a special case some controllers have a 39bit address
106 mode that is as efficient as 32bit (aic79xx). Don't force
107 SAC for these. Assume all masks <= 40 bits are of this
108 type. Normally this doesn't make any difference, but gives
109 more gentle handling of IOMMU overflow. */
110 if (iommu_sac_force && (mask >= DMA_40BIT_MASK)) {
111 dev_info(dev, "Force SAC with mask %lx\n", mask);
112 return 0;
115 return 1;
117 EXPORT_SYMBOL(iommu_dma_supported);
119 #endif