]> err.no Git - linux-2.6/blobdiff - arch/alpha/kernel/pci_iommu.c
Merge branch 'for-2.6.26' of master.kernel.org:/pub/scm/linux/kernel/git/olof/pasemi
[linux-2.6] / arch / alpha / kernel / pci_iommu.c
index 54540c369c9087fa9d2e7d7dc1b2df0783f7d2b7..dd6e334ab9e127d61338f27bb28de710689aa6ab 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/scatterlist.h>
 #include <linux/log2.h>
 #include <linux/dma-mapping.h>
+#include <linux/iommu-helper.h>
 
 #include <asm/io.h>
 #include <asm/hwrpb.h>
@@ -31,7 +32,6 @@
 #endif
 
 #define DEBUG_NODIRECT 0
-#define DEBUG_FORCEDAC 0
 
 #define ISA_DMA_MASK           0x00ffffff
 
@@ -126,14 +126,6 @@ iommu_arena_new(struct pci_controller *hose, dma_addr_t base,
        return iommu_arena_new_node(0, hose, base, window_size, align);
 }
 
-static inline int is_span_boundary(unsigned int index, unsigned int nr,
-                                  unsigned long shift,
-                                  unsigned long boundary_size)
-{
-       shift = (shift + index) & (boundary_size - 1);
-       return shift + nr > boundary_size;
-}
-
 /* Must be called with the arena lock held */
 static long
 iommu_arena_find_pages(struct device *dev, struct pci_iommu_arena *arena,
@@ -145,15 +137,13 @@ iommu_arena_find_pages(struct device *dev, struct pci_iommu_arena *arena,
        unsigned long base;
        unsigned long boundary_size;
 
-       BUG_ON(arena->dma_base & ~PAGE_MASK);
        base = arena->dma_base >> PAGE_SHIFT;
-       if (dev)
-               boundary_size = ALIGN(dma_get_max_seg_size(dev) + 1, PAGE_SIZE)
-                       >> PAGE_SHIFT;
-       else
-               boundary_size = ALIGN(1UL << 32, PAGE_SIZE) >> PAGE_SHIFT;
-
-       BUG_ON(!is_power_of_2(boundary_size));
+       if (dev) {
+               boundary_size = dma_get_seg_boundary(dev) + 1;
+               boundary_size >>= PAGE_SHIFT;
+       } else {
+               boundary_size = 1UL << (32 - PAGE_SHIFT);
+       }
 
        /* Search forward for the first mask-aligned sequence of N free ptes */
        ptes = arena->ptes;
@@ -163,7 +153,7 @@ iommu_arena_find_pages(struct device *dev, struct pci_iommu_arena *arena,
 
 again:
        while (i < n && p+i < nent) {
-               if (!i && is_span_boundary(p, n, base, boundary_size)) {
+               if (!i && iommu_is_span_boundary(p, n, base, boundary_size)) {
                        p = ALIGN(p + 1, mask + 1);
                        goto again;
                }
@@ -434,11 +424,13 @@ EXPORT_SYMBOL(pci_unmap_page);
    else DMA_ADDRP is undefined.  */
 
 void *
-pci_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_addrp)
+__pci_alloc_consistent(struct pci_dev *pdev, size_t size,
+                      dma_addr_t *dma_addrp, gfp_t gfp)
 {
        void *cpu_addr;
        long order = get_order(size);
-       gfp_t gfp = GFP_ATOMIC;
+
+       gfp &= ~GFP_DMA;
 
 try_again:
        cpu_addr = (void *)__get_free_pages(gfp, order);
@@ -468,7 +460,7 @@ try_again:
 
        return cpu_addr;
 }
-EXPORT_SYMBOL(pci_alloc_consistent);
+EXPORT_SYMBOL(__pci_alloc_consistent);
 
 /* Free and unmap a consistent DMA buffer.  CPU_ADDR and DMA_ADDR must
    be values that were returned from pci_alloc_consistent.  SIZE must