aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/pci-dma.c
diff options
context:
space:
mode:
authorGlauber Costa <gcosta@redhat.com>2008-04-08 12:20:55 -0400
committerIngo Molnar <mingo@elte.hu>2008-04-19 13:19:57 -0400
commit8e0c379718ef32967deea55937895bfc9b493dd8 (patch)
tree4176210a3359f4d7421a8b7e0cec29e848e8d68a /arch/x86/kernel/pci-dma.c
parentbca5c09663030bdd18ab1b3ccb6671f663c3345a (diff)
x86: merge dma_supported
The code for both arches are very similar, so this patch merge them. Signed-off-by: Glauber Costa <gcosta@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/pci-dma.c')
-rw-r--r--arch/x86/kernel/pci-dma.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 48cccbe51aa5..7d3bd652c36f 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -14,6 +14,8 @@ EXPORT_SYMBOL(forbid_dac);
14const struct dma_mapping_ops *dma_ops; 14const struct dma_mapping_ops *dma_ops;
15EXPORT_SYMBOL(dma_ops); 15EXPORT_SYMBOL(dma_ops);
16 16
17int iommu_sac_force __read_mostly = 0;
18
17#ifdef CONFIG_IOMMU_DEBUG 19#ifdef CONFIG_IOMMU_DEBUG
18int panic_on_overflow __read_mostly = 1; 20int panic_on_overflow __read_mostly = 1;
19int force_iommu __read_mostly = 1; 21int force_iommu __read_mostly = 1;
@@ -103,6 +105,48 @@ void __init pci_iommu_alloc(void)
103} 105}
104#endif 106#endif
105 107
108int dma_supported(struct device *dev, u64 mask)
109{
110#ifdef CONFIG_PCI
111 if (mask > 0xffffffff && forbid_dac > 0) {
112 printk(KERN_INFO "PCI: Disallowing DAC for device %s\n",
113 dev->bus_id);
114 return 0;
115 }
116#endif
117
118 if (dma_ops->dma_supported)
119 return dma_ops->dma_supported(dev, mask);
120
121 /* Copied from i386. Doesn't make much sense, because it will
122 only work for pci_alloc_coherent.
123 The caller just has to use GFP_DMA in this case. */
124 if (mask < DMA_24BIT_MASK)
125 return 0;
126
127 /* Tell the device to use SAC when IOMMU force is on. This
128 allows the driver to use cheaper accesses in some cases.
129
130 Problem with this is that if we overflow the IOMMU area and
131 return DAC as fallback address the device may not handle it
132 correctly.
133
134 As a special case some controllers have a 39bit address
135 mode that is as efficient as 32bit (aic79xx). Don't force
136 SAC for these. Assume all masks <= 40 bits are of this
137 type. Normally this doesn't make any difference, but gives
138 more gentle handling of IOMMU overflow. */
139 if (iommu_sac_force && (mask >= DMA_40BIT_MASK)) {
140 printk(KERN_INFO "%s: Force SAC with mask %Lx\n",
141 dev->bus_id, mask);
142 return 0;
143 }
144
145 return 1;
146}
147EXPORT_SYMBOL(dma_supported);
148
149
106static int __init pci_iommu_init(void) 150static int __init pci_iommu_init(void)
107{ 151{
108#ifdef CONFIG_CALGARY_IOMMU 152#ifdef CONFIG_CALGARY_IOMMU