aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap/iovmm.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/plat-omap/iovmm.c')
-rw-r--r--arch/arm/plat-omap/iovmm.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/arch/arm/plat-omap/iovmm.c b/arch/arm/plat-omap/iovmm.c
index 6dc1296c8c77..51ef43e8def6 100644
--- a/arch/arm/plat-omap/iovmm.c
+++ b/arch/arm/plat-omap/iovmm.c
@@ -271,20 +271,21 @@ static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da,
271 size_t bytes, u32 flags) 271 size_t bytes, u32 flags)
272{ 272{
273 struct iovm_struct *new, *tmp; 273 struct iovm_struct *new, *tmp;
274 u32 start, prev_end, alignement; 274 u32 start, prev_end, alignment;
275 275
276 if (!obj || !bytes) 276 if (!obj || !bytes)
277 return ERR_PTR(-EINVAL); 277 return ERR_PTR(-EINVAL);
278 278
279 start = da; 279 start = da;
280 alignement = PAGE_SIZE; 280 alignment = PAGE_SIZE;
281 281
282 if (flags & IOVMF_DA_ANON) { 282 if (~flags & IOVMF_DA_FIXED) {
283 start = obj->da_start; 283 /* Don't map address 0 */
284 start = obj->da_start ? obj->da_start : alignment;
284 285
285 if (flags & IOVMF_LINEAR) 286 if (flags & IOVMF_LINEAR)
286 alignement = iopgsz_max(bytes); 287 alignment = iopgsz_max(bytes);
287 start = roundup(start, alignement); 288 start = roundup(start, alignment);
288 } else if (start < obj->da_start || start > obj->da_end || 289 } else if (start < obj->da_start || start > obj->da_end ||
289 obj->da_end - start < bytes) { 290 obj->da_end - start < bytes) {
290 return ERR_PTR(-EINVAL); 291 return ERR_PTR(-EINVAL);
@@ -303,8 +304,8 @@ static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da,
303 if (tmp->da_start > start && (tmp->da_start - start) >= bytes) 304 if (tmp->da_start > start && (tmp->da_start - start) >= bytes)
304 goto found; 305 goto found;
305 306
306 if (tmp->da_end >= start && flags & IOVMF_DA_ANON) 307 if (tmp->da_end >= start && ~flags & IOVMF_DA_FIXED)
307 start = roundup(tmp->da_end + 1, alignement); 308 start = roundup(tmp->da_end + 1, alignment);
308 309
309 prev_end = tmp->da_end; 310 prev_end = tmp->da_end;
310 } 311 }
@@ -650,7 +651,6 @@ u32 iommu_vmap(struct iommu *obj, u32 da, const struct sg_table *sgt,
650 flags &= IOVMF_HW_MASK; 651 flags &= IOVMF_HW_MASK;
651 flags |= IOVMF_DISCONT; 652 flags |= IOVMF_DISCONT;
652 flags |= IOVMF_MMIO; 653 flags |= IOVMF_MMIO;
653 flags |= (da ? IOVMF_DA_FIXED : IOVMF_DA_ANON);
654 654
655 da = __iommu_vmap(obj, da, sgt, va, bytes, flags); 655 da = __iommu_vmap(obj, da, sgt, va, bytes, flags);
656 if (IS_ERR_VALUE(da)) 656 if (IS_ERR_VALUE(da))
@@ -690,7 +690,7 @@ EXPORT_SYMBOL_GPL(iommu_vunmap);
690 * @flags: iovma and page property 690 * @flags: iovma and page property
691 * 691 *
692 * Allocate @bytes linearly and creates 1-n-1 mapping and returns 692 * Allocate @bytes linearly and creates 1-n-1 mapping and returns
693 * @da again, which might be adjusted if 'IOVMF_DA_ANON' is set. 693 * @da again, which might be adjusted if 'IOVMF_DA_FIXED' is not set.
694 */ 694 */
695u32 iommu_vmalloc(struct iommu *obj, u32 da, size_t bytes, u32 flags) 695u32 iommu_vmalloc(struct iommu *obj, u32 da, size_t bytes, u32 flags)
696{ 696{
@@ -709,7 +709,6 @@ u32 iommu_vmalloc(struct iommu *obj, u32 da, size_t bytes, u32 flags)
709 flags &= IOVMF_HW_MASK; 709 flags &= IOVMF_HW_MASK;
710 flags |= IOVMF_DISCONT; 710 flags |= IOVMF_DISCONT;
711 flags |= IOVMF_ALLOC; 711 flags |= IOVMF_ALLOC;
712 flags |= (da ? IOVMF_DA_FIXED : IOVMF_DA_ANON);
713 712
714 sgt = sgtable_alloc(bytes, flags, da, 0); 713 sgt = sgtable_alloc(bytes, flags, da, 0);
715 if (IS_ERR(sgt)) { 714 if (IS_ERR(sgt)) {
@@ -780,7 +779,7 @@ static u32 __iommu_kmap(struct iommu *obj, u32 da, u32 pa, void *va,
780 * @flags: iovma and page property 779 * @flags: iovma and page property
781 * 780 *
782 * Creates 1-1-1 mapping and returns @da again, which can be 781 * Creates 1-1-1 mapping and returns @da again, which can be
783 * adjusted if 'IOVMF_DA_ANON' is set. 782 * adjusted if 'IOVMF_DA_FIXED' is not set.
784 */ 783 */
785u32 iommu_kmap(struct iommu *obj, u32 da, u32 pa, size_t bytes, 784u32 iommu_kmap(struct iommu *obj, u32 da, u32 pa, size_t bytes,
786 u32 flags) 785 u32 flags)
@@ -799,7 +798,6 @@ u32 iommu_kmap(struct iommu *obj, u32 da, u32 pa, size_t bytes,
799 flags &= IOVMF_HW_MASK; 798 flags &= IOVMF_HW_MASK;
800 flags |= IOVMF_LINEAR; 799 flags |= IOVMF_LINEAR;
801 flags |= IOVMF_MMIO; 800 flags |= IOVMF_MMIO;
802 flags |= (da ? IOVMF_DA_FIXED : IOVMF_DA_ANON);
803 801
804 da = __iommu_kmap(obj, da, pa, va, bytes, flags); 802 da = __iommu_kmap(obj, da, pa, va, bytes, flags);
805 if (IS_ERR_VALUE(da)) 803 if (IS_ERR_VALUE(da))
@@ -838,7 +836,7 @@ EXPORT_SYMBOL_GPL(iommu_kunmap);
838 * @flags: iovma and page property 836 * @flags: iovma and page property
839 * 837 *
840 * Allocate @bytes linearly and creates 1-1-1 mapping and returns 838 * Allocate @bytes linearly and creates 1-1-1 mapping and returns
841 * @da again, which might be adjusted if 'IOVMF_DA_ANON' is set. 839 * @da again, which might be adjusted if 'IOVMF_DA_FIXED' is not set.
842 */ 840 */
843u32 iommu_kmalloc(struct iommu *obj, u32 da, size_t bytes, u32 flags) 841u32 iommu_kmalloc(struct iommu *obj, u32 da, size_t bytes, u32 flags)
844{ 842{
@@ -858,7 +856,6 @@ u32 iommu_kmalloc(struct iommu *obj, u32 da, size_t bytes, u32 flags)
858 flags &= IOVMF_HW_MASK; 856 flags &= IOVMF_HW_MASK;
859 flags |= IOVMF_LINEAR; 857 flags |= IOVMF_LINEAR;
860 flags |= IOVMF_ALLOC; 858 flags |= IOVMF_ALLOC;
861 flags |= (da ? IOVMF_DA_FIXED : IOVMF_DA_ANON);
862 859
863 da = __iommu_kmap(obj, da, pa, va, bytes, flags); 860 da = __iommu_kmap(obj, da, pa, va, bytes, flags);
864 if (IS_ERR_VALUE(da)) 861 if (IS_ERR_VALUE(da))