xen: cleancache shim to Xen Transcendent Memory
[linux-2.6/next.git] / arch / ia64 / kernel / pci-dma.c
blobf6b1ff0aea76f95b094c01be87a7b4c98393a3f2
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 int iommu_pass_through;
37 /* Dummy device used for NULL arguments (normally ISA). Better would
38 be probably a smaller DMA mask, but this is bug-to-bug compatible
39 to i386. */
40 struct device fallback_dev = {
41 .init_name = "fallback device",
42 .coherent_dma_mask = DMA_BIT_MASK(32),
43 .dma_mask = &fallback_dev.coherent_dma_mask,
46 extern struct dma_map_ops intel_dma_ops;
48 static int __init pci_iommu_init(void)
50 if (iommu_detected)
51 intel_iommu_init();
53 return 0;
56 /* Must execute after PCI subsystem */
57 fs_initcall(pci_iommu_init);
59 void pci_iommu_shutdown(void)
61 return;
64 void __init
65 iommu_dma_init(void)
67 return;
70 int iommu_dma_supported(struct device *dev, u64 mask)
72 /* Copied from i386. Doesn't make much sense, because it will
73 only work for pci_alloc_coherent.
74 The caller just has to use GFP_DMA in this case. */
75 if (mask < DMA_BIT_MASK(24))
76 return 0;
78 /* Tell the device to use SAC when IOMMU force is on. This
79 allows the driver to use cheaper accesses in some cases.
81 Problem with this is that if we overflow the IOMMU area and
82 return DAC as fallback address the device may not handle it
83 correctly.
85 As a special case some controllers have a 39bit address
86 mode that is as efficient as 32bit (aic79xx). Don't force
87 SAC for these. Assume all masks <= 40 bits are of this
88 type. Normally this doesn't make any difference, but gives
89 more gentle handling of IOMMU overflow. */
90 if (iommu_sac_force && (mask >= DMA_BIT_MASK(40))) {
91 dev_info(dev, "Force SAC with mask %llx\n", mask);
92 return 0;
95 return 1;
97 EXPORT_SYMBOL(iommu_dma_supported);
99 void __init pci_iommu_alloc(void)
101 dma_ops = &intel_dma_ops;
103 dma_ops->sync_single_for_cpu = machvec_dma_sync_single;
104 dma_ops->sync_sg_for_cpu = machvec_dma_sync_sg;
105 dma_ops->sync_single_for_device = machvec_dma_sync_single;
106 dma_ops->sync_sg_for_device = machvec_dma_sync_sg;
107 dma_ops->dma_supported = iommu_dma_supported;
110 * The order of these functions is important for
111 * fall-back/fail-over reasons
113 detect_intel_iommu();
115 #ifdef CONFIG_SWIOTLB
116 pci_swiotlb_init();
117 #endif
120 #endif