Merge "msm: vidc: Handle cases where secure domain is not present in DT file"
diff --git a/drivers/media/platform/msm/vidc/msm_v4l2_vidc.c b/drivers/media/platform/msm/vidc/msm_v4l2_vidc.c
index 54047eb..5d360bb 100644
--- a/drivers/media/platform/msm/vidc/msm_v4l2_vidc.c
+++ b/drivers/media/platform/msm/vidc/msm_v4l2_vidc.c
@@ -879,10 +879,14 @@
 	res->iommu_maps_size = MAX_MAP;
 	for (i = 0; i < MAX_MAP; i++) {
 		num_elements = get_u32_array_num_elements(pdev, names[i]);
-		if (num_elements == 0) {
-			dprintk(VIDC_ERR,
-				"no elements in iommu map :%s\n", names[i]);
-			goto error;
+		if ((num_elements == 0)) {
+			if (i == NS_MAP) {
+				dprintk(VIDC_ERR,
+				"Domain not found in dtsi file :%s\n",
+				names[i]);
+				goto error;
+			} else
+				continue;
 		}
 		memcpy(&res->iommu_maps[i].name, names[i],
 				strlen(names[i]));
diff --git a/drivers/media/platform/msm/vidc/venus_hfi.c b/drivers/media/platform/msm/vidc/venus_hfi.c
index 52150e9..6d07165 100644
--- a/drivers/media/platform/msm/vidc/venus_hfi.c
+++ b/drivers/media/platform/msm/vidc/venus_hfi.c
@@ -2063,6 +2063,8 @@
 			sizeof(io_map[NS_MAP].ctx));
 
 	for (i = 0; i < MAX_MAP; i++) {
+		if (!res->iommu_maps[i].addr_range[1])
+			continue;
 		memcpy(io_map[i].addr_range, &res->iommu_maps[i].addr_range,
 				sizeof(u32) * 2);
 
@@ -2481,6 +2483,8 @@
 
 	for (i = 0; i < MAX_MAP; i++) {
 		io_map = &device->resources.io_map[i];
+		if (!io_map->domain)
+			continue;
 		dev = msm_iommu_get_ctx(io_map->ctx);
 		domain = msm_get_iommu_domain(io_map->domain);
 		if (IS_ERR_OR_NULL(domain)) {
@@ -2565,7 +2569,6 @@
 	unsigned int resp = 0;
 	int rc = 0;
 	struct msm_vidc_iommu_info *io_map;
-
 	if (!device)
 		return -EINVAL;
 
@@ -2574,6 +2577,8 @@
 		dprintk(VIDC_ERR, "invalid params: %p\n", io_map);
 		return -EINVAL;
 	}
+	if (!io_map[CP_MAP].addr_range[1])
+		return 0;
 	memprot.cp_start = 0x0;
 	memprot.cp_size = io_map[CP_MAP].addr_range[0] +
 			io_map[CP_MAP].addr_range[1];