msm: iommu: Allow mapping of extra iova space
In some cases, it may be adventageous to map more iommu
virtual address space than there is actual buffer space.
Add apis to map the extra iova space to a dummy buffer.
Change-Id: I93420cddaac7256e95e98650bc59e61faf56e55e
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
diff --git a/arch/arm/mach-msm/iommu_domains.c b/arch/arm/mach-msm/iommu_domains.c
index e849cdb..600a2e9 100644
--- a/arch/arm/mach-msm/iommu_domains.c
+++ b/arch/arm/mach-msm/iommu_domains.c
@@ -20,6 +20,9 @@
#include <mach/iommu_domains.h>
#include <mach/socinfo.h>
+/* dummy 4k for overmapping */
+char iommu_dummy[2*PAGE_SIZE-4];
+
struct msm_iommu_domain {
/* iommu domain to map in */
struct iommu_domain *domain;
@@ -159,6 +162,41 @@
}
};
+int msm_iommu_map_extra(struct iommu_domain *domain,
+ unsigned long start_iova,
+ unsigned long size,
+ int cached)
+{
+ int i, ret;
+ unsigned long temp_iova;
+
+ for (i = size, temp_iova = start_iova; i > 0; i -= SZ_4K,
+ temp_iova += SZ_4K) {
+ ret = iommu_map(domain, temp_iova,
+ PFN_ALIGN(virt_to_phys(iommu_dummy)),
+ get_order(SZ_4K),
+ 0);
+
+ if (ret) {
+ pr_err("%s: could not map %lx to dummy page in domain"
+ " %p\n",
+ __func__, temp_iova, domain);
+ goto out;
+ }
+ }
+
+ return 0;
+
+out:
+
+ for ( ; i < size; i += SZ_4K, temp_iova -= SZ_4K)
+ iommu_unmap(domain, temp_iova, get_order(SZ_4K));
+
+ return -EINVAL;
+
+}
+
+
struct iommu_domain *msm_get_iommu_domain(int domain_num)
{
if (domain_num >= 0 && domain_num < MAX_DOMAINS)