Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 into sh/for...
[sfrench/cifs-2.6.git] / arch / arm / plat-omap / iovmm.c
index 57f7122a09191756ef9ef61577752f67702e170c..936aef1971cd320afd086f099d59a4d0b9958281 100644 (file)
@@ -18,8 +18,8 @@
 #include <asm/cacheflush.h>
 #include <asm/mach/map.h>
 
-#include <mach/iommu.h>
-#include <mach/iovmm.h>
+#include <plat/iommu.h>
+#include <plat/iovmm.h>
 
 #include "iopgtable.h"
 
@@ -47,7 +47,7 @@
  *     'va':   mpu virtual address
  *
  *     'c':    contiguous memory area
- *     'd':    dicontiguous memory area
+ *     'd':    discontiguous memory area
  *     'a':    anonymous memory allocation
  *     '()':   optional feature
  *
@@ -363,8 +363,9 @@ void *da_to_va(struct iommu *obj, u32 da)
                goto out;
        }
        va = area->va;
-       mutex_unlock(&obj->mmap_lock);
 out:
+       mutex_unlock(&obj->mmap_lock);
+
        return va;
 }
 EXPORT_SYMBOL_GPL(da_to_va);
@@ -391,14 +392,13 @@ static void sgtable_fill_vmalloc(struct sg_table *sgt, void *_va)
        }
 
        va_end = _va + PAGE_SIZE * i;
-       flush_cache_vmap((unsigned long)_va, (unsigned long)va_end);
 }
 
 static inline void sgtable_drain_vmalloc(struct sg_table *sgt)
 {
        /*
         * Actually this is not necessary at all, just exists for
-        * consistency of the code readibility.
+        * consistency of the code readability.
         */
        BUG_ON(!sgt);
 }
@@ -426,15 +426,13 @@ static void sgtable_fill_kmalloc(struct sg_table *sgt, u32 pa, size_t len)
                len -= bytes;
        }
        BUG_ON(len);
-
-       clean_dcache_area(va, len);
 }
 
 static inline void sgtable_drain_kmalloc(struct sg_table *sgt)
 {
        /*
         * Actually this is not necessary at all, just exists for
-        * consistency of the code readibility
+        * consistency of the code readability
         */
        BUG_ON(!sgt);
 }
@@ -448,7 +446,7 @@ static int map_iovm_area(struct iommu *obj, struct iovm_struct *new,
        struct scatterlist *sg;
        u32 da = new->da_start;
 
-       if (!obj || !new || !sgt)
+       if (!obj || !sgt)
                return -EINVAL;
 
        BUG_ON(!sgtable_ok(sgt));
@@ -616,7 +614,7 @@ u32 iommu_vmap(struct iommu *obj, u32 da, const struct sg_table *sgt,
                 u32 flags)
 {
        size_t bytes;
-       void *va;
+       void *va = NULL;
 
        if (!obj || !obj->dev || !sgt)
                return -EINVAL;
@@ -626,9 +624,11 @@ u32 iommu_vmap(struct iommu *obj, u32 da, const struct sg_table *sgt,
                return -EINVAL;
        bytes = PAGE_ALIGN(bytes);
 
-       va = vmap_sg(sgt);
-       if (IS_ERR(va))
-               return PTR_ERR(va);
+       if (flags & IOVMF_MMIO) {
+               va = vmap_sg(sgt);
+               if (IS_ERR(va))
+                       return PTR_ERR(va);
+       }
 
        flags &= IOVMF_HW_MASK;
        flags |= IOVMF_DISCONT;