summaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/pci-dma_32.c
diff options
context:
space:
mode:
authorGlauber Costa2008-04-09 18:18:08 +0200
committerIngo Molnar2008-04-19 19:19:58 +0200
commitda60cab4dd922cd933e82bace490f6155a32a90e (patch)
tree19d1df02cbe4cf370f383fcc466298a699fe757e /arch/x86/kernel/pci-dma_32.c
parentx86: remove kludge from x86_64 (diff)
downloadkernel-qcow2-linux-da60cab4dd922cd933e82bace490f6155a32a90e.tar.gz
kernel-qcow2-linux-da60cab4dd922cd933e82bace490f6155a32a90e.tar.xz
kernel-qcow2-linux-da60cab4dd922cd933e82bace490f6155a32a90e.zip
x86: return conditional to mmu
Just return our allocation if we don't have an mmu. For i386, where this patch is being applied, we never have. So our goal is just to have the code to look like x86_64's. 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_32.c')
-rw-r--r--arch/x86/kernel/pci-dma_32.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/arch/x86/kernel/pci-dma_32.c b/arch/x86/kernel/pci-dma_32.c
index 5450bd142cb0..f134de3833a2 100644
--- a/arch/x86/kernel/pci-dma_32.c
+++ b/arch/x86/kernel/pci-dma_32.c
@@ -116,12 +116,42 @@ again:
gfp = (gfp & ~GFP_DMA32) | GFP_DMA;
goto again;
}
+
+ /* Let low level make its own zone decisions */
+ gfp &= ~(GFP_DMA32|GFP_DMA);
+
+ if (dma_ops->alloc_coherent)
+ return dma_ops->alloc_coherent(dev, size,
+ dma_handle, gfp);
+ return NULL;
+
}
memset(ret, 0, size);
- *dma_handle = bus;
+ if (!mmu) {
+ *dma_handle = bus;
+ return ret;
+ }
+ }
+
+ if (dma_ops->alloc_coherent) {
+ free_pages((unsigned long)ret, get_order(size));
+ gfp &= ~(GFP_DMA|GFP_DMA32);
+ return dma_ops->alloc_coherent(dev, size, dma_handle, gfp);
+ }
+
+ if (dma_ops->map_simple) {
+ *dma_handle = dma_ops->map_simple(dev, virt_to_phys(ret),
+ size,
+ PCI_DMA_BIDIRECTIONAL);
+ if (*dma_handle != bad_dma_address)
+ return ret;
}
- return ret;
+ if (panic_on_overflow)
+ panic("dma_alloc_coherent: IOMMU overflow by %lu bytes\n",
+ (unsigned long)size);
+ free_pages((unsigned long)ret, get_order(size));
+ return NULL;
}
EXPORT_SYMBOL(dma_alloc_coherent);