msm: Allow iova address alignment specification

Some clients have specific alignment requirements for
iova addresses. Allow those requirements to be specified
via the upper bits of the flag field. Since all iommu
alignment must be at least 4k, the lower bits can specify
other options while the upper bits specify the alignment.

Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
diff --git a/arch/arm/mach-msm/subsystem_map.c b/arch/arm/mach-msm/subsystem_map.c
index 93aabf2..d242370 100644
--- a/arch/arm/mach-msm/subsystem_map.c
+++ b/arch/arm/mach-msm/subsystem_map.c
@@ -349,6 +349,7 @@
 	}
 
 	if ((flags & MSM_SUBSYSTEM_MAP_IOVA) && subsys_ids) {
+		unsigned int min_align;
 
 		pg_size = SZ_4K;
 
@@ -369,6 +370,13 @@
 		}
 
 		order = get_order(pg_size);
+
+		/*
+		 * The alignment must be specified as the exact value wanted
+		 * e.g. 8k alignment must pass (0x2000 | other flags)
+		 */
+		min_align = flags & ~(SZ_4K - 1);
+
 		for (i = 0; i < nsubsys; i++) {
 			if (!subsys_validate(subsys_ids[i])) {
 				buf->iova[i] = phys;
@@ -378,7 +386,8 @@
 			d = msm_subsystem_get_domain(subsys_ids[i]);
 
 			iova_start = allocate_iova_address(length,
-						subsys_ids[i], pg_size);
+						subsys_ids[i],
+						max(min_align, pg_size));
 
 			if (!iova_start) {
 				pr_err("%s: could not allocate iova address\n",