Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 640a24da authored by Shalaj Jain's avatar Shalaj Jain
Browse files

ion: Remove secure and unsecure buffer APIs



These APIs are deprecated as securing and unsecuring for secure
buffers is done on allocation and free respectively by the secure
heap layer. Clients don't have to call these explicitly.

Change-Id: If88cd1c47cba346446ebdcad494850b54ba954ab
Signed-off-by: default avatarShalaj Jain <shalajj@codeaurora.org>
parent 77af73d4
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -147,16 +147,6 @@ static int msm_isp_prepare_isp_buf(struct msm_isp_buf_mgr *buf_mgr,
				__func__, mapped_info->handle);
			goto ion_map_error;
		}
		if (buf_mgr->secure_enable == SECURE_MODE) {
			pr_debug("%s: Securing the ION buffers\n", __func__);
			rc = msm_ion_secure_buffer(buf_mgr->client,
				mapped_info->handle, CAMERA_SECURE_CP_USAGE, 0);
			if (rc < 0) {
				pr_err("%s: Failed to secure ion buffers rc=%d\n",
					__func__, rc);
				goto ion_map_error;
			}
		}
		if (ion_map_iommu(buf_mgr->client, mapped_info->handle,
				domain_num, 0, SZ_4K,
				0, &(mapped_info->paddr),
@@ -216,12 +206,6 @@ static void msm_isp_unprepare_v4l2_buf(
				ion_unmap_iommu(buf_mgr->client,
					mapped_info->handle,
					domain_num, 0);
				if (buf_mgr->secure_enable == SECURE_MODE) {
					pr_debug("%s: Unsecuring the ION buffers\n",
						__func__);
					msm_ion_unsecure_buffer(buf_mgr->client,
						mapped_info->handle);
				}
				ion_free(buf_mgr->client, mapped_info->handle);

				list_del_init(&buf_pending->list);
+1 −38
Original line number Diff line number Diff line
@@ -24,28 +24,6 @@ struct smem_client {
	struct msm_vidc_platform_resources *res;
};

static u32 get_tz_usage(struct smem_client *client, enum hal_buffer buffer_type)
{
	int i;
	struct buffer_usage_set *buffer_usage_set;
	struct buffer_usage_table *buffer_usage_tbl;

	buffer_usage_set = &client->res->buffer_usage_set;
	if (!buffer_usage_set) {
		dprintk(VIDC_DBG, "no buffer usage set present!\n");
		return 0;
	}

	for (i = 0; i < buffer_usage_set->count; i++) {
		buffer_usage_tbl = &buffer_usage_set->buffer_usage_tbl[i];
		if (buffer_usage_tbl->buffer_type & buffer_type)
			return buffer_usage_tbl->tz_usage;
	}
	dprintk(VIDC_DBG, "No tz usage found for buffer type: %x\n",
			buffer_type);
	return 0;
}

static int get_device_address(struct smem_client *smem_client,
		struct ion_handle *hndl, unsigned long align,
		ion_phys_addr_t *iova, unsigned long *buffer_size,
@@ -78,14 +56,6 @@ static int get_device_address(struct smem_client *smem_client,
		}
	}

	if (flags & SMEM_SECURE) {
		rc = msm_ion_secure_buffer(clnt, hndl,
			get_tz_usage(smem_client, buffer_type), 0);
		if (rc) {
			dprintk(VIDC_ERR, "Failed to secure memory\n");
			goto mem_domain_get_failed;
		}
	}
	if (is_iommu_present(smem_client->res)) {
		dprintk(VIDC_DBG,
				"Calling ion_map_iommu - domain: %d, partition: %d\n",
@@ -102,13 +72,10 @@ static int get_device_address(struct smem_client *smem_client,
	}
	if (rc) {
		dprintk(VIDC_ERR, "ion memory map failed - %d\n", rc);
		goto mem_map_failed;
		goto mem_domain_get_failed;
	}

	return 0;
mem_map_failed:
	if (flags & SMEM_SECURE)
		msm_ion_unsecure_buffer(clnt, hndl);
mem_domain_get_failed:
	return rc;
}
@@ -140,10 +107,6 @@ static void put_device_address(struct smem_client *smem_client,
		trace_msm_smem_buffer_iommu_op_end("UNMAP", domain_num,
				partition_num, 0, 0, 0);
	}
	if (flags & SMEM_SECURE) {
		if (msm_ion_unsecure_buffer(clnt, hndl))
			dprintk(VIDC_ERR, "Failed to unsecure memory\n");
	}
}

static int ion_user_to_kernel(struct smem_client *client, int fd, u32 offset,
+1 −17
Original line number Diff line number Diff line
@@ -666,12 +666,6 @@ static void __vpu_mem_release_handle(void *mem_handle, u32 device_id)
				ion_unmap_iommu(ion_client, ion_handle,
					handle->domain_num[i], 0);

			if (handle->flags & MEM_SECURE) {
				if (msm_ion_unsecure_buffer(ion_client,
						ion_handle))
					pr_warn("Failed to unsecure memory\n");
			}

			handle->mapped &= ~(1 << i);
			handle->domain_num[i] = -1;
			handle->device_addr[i] = 0;
@@ -733,16 +727,8 @@ static int __vpu_mem_map_handle(struct vpu_mem_handle *handle, u32 device_id,

		domain_number = handle->domain_num[device_id];

		if (handle->flags & MEM_SECURE) { /* handle secure buffers */
			pr_debug("Securing ION buffer\n");
		if (handle->flags & MEM_SECURE) /* handle secure buffers */
			align = SZ_1M;
			ret = msm_ion_secure_buffer(ion_client, ion_handle,
					VIDEO_PIXEL, 0);
			if (ret) {
				pr_err("Failed to secure memory\n");
				return ret;
			}
		}

		pr_debug("Using IOMMU mapping\n");
		ret = ion_map_iommu(ion_client, ion_handle, domain_number, 0,
@@ -757,8 +743,6 @@ static int __vpu_mem_map_handle(struct vpu_mem_handle *handle, u32 device_id,

	if (ret) {
		pr_err("Failed to map ion buffer\n");
		if (handle->flags & MEM_SECURE)
			msm_ion_unsecure_buffer(ion_client, ion_handle);
		return ret;
	}

+2 −32
Original line number Diff line number Diff line
@@ -766,20 +766,11 @@ static int venc_map_user_to_kernel(struct venc_inst *inst,
	mregion->kvaddr = inst->secure ? NULL :
		venc_map_kernel(venc_ion_client, mregion->ion_handle);

	if (inst->secure) {
		rc = msm_ion_secure_buffer(venc_ion_client,
			mregion->ion_handle, VIDEO_BITSTREAM, 0);
		if (rc) {
			WFD_MSG_ERR("Failed to secure output buffer\n");
			goto venc_map_iommu_map_fail;
		}
	}

	rc = msm_vidc_get_iommu_domain_partition(inst->vidc_context,
			flags, BUF_TYPE_OUTPUT, &domain, &partition);
	if (rc) {
		WFD_MSG_ERR("Failed to get domain for output buffer\n");
		goto venc_domain_fail;
		goto venc_map_iommu_map_fail;
	}

	rc = ion_map_iommu(venc_ion_client, mregion->ion_handle,
@@ -798,9 +789,6 @@ static int venc_map_user_to_kernel(struct venc_inst *inst,
venc_map_iommu_size_fail:
	ion_unmap_iommu(venc_ion_client, mregion->ion_handle,
			domain, partition);
venc_domain_fail:
	if (inst->secure)
		msm_ion_unsecure_buffer(venc_ion_client, mregion->ion_handle);
venc_map_iommu_map_fail:
	if (!inst->secure && !IS_ERR_OR_NULL(mregion->kvaddr))
		venc_unmap_kernel(venc_ion_client, mregion->ion_handle);
@@ -841,9 +829,6 @@ static int venc_unmap_user_to_kernel(struct venc_inst *inst,
		mregion->kvaddr = NULL;
	}

	if (inst->secure)
		msm_ion_unsecure_buffer(venc_ion_client, mregion->ion_handle);

	ion_free(venc_ion_client, mregion->ion_handle);
	return rc;
}
@@ -1374,20 +1359,11 @@ long venc_mmap(struct v4l2_subdev *sd, void *arg)
		goto venc_map_bad_align;
	}

	if (inst->secure) {
		rc = msm_ion_secure_buffer(mmap->ion_client,
				mregion->ion_handle, VIDEO_PIXEL, 0);
		if (rc) {
			WFD_MSG_ERR("Failed to secure input buffer\n");
			goto venc_map_bad_align;
		}
	}

	rc = msm_vidc_get_iommu_domain_partition(inst->vidc_context,
			flags, BUF_TYPE_INPUT, &domain, &partition);
	if (rc) {
		WFD_MSG_ERR("Failed to get domain for output buffer\n");
		goto venc_map_domain_fail;
		goto venc_map_bad_align;
	}

	rc = ion_map_iommu(mmap->ion_client, mregion->ion_handle,
@@ -1409,9 +1385,6 @@ long venc_mmap(struct v4l2_subdev *sd, void *arg)
venc_map_iommu_size_fail:
	ion_unmap_iommu(venc_ion_client, mregion->ion_handle,
			domain, partition);
venc_map_domain_fail:
	if (inst->secure)
		msm_ion_unsecure_buffer(mmap->ion_client, mregion->ion_handle);
venc_map_bad_align:
	return rc;
}
@@ -1455,9 +1428,6 @@ long venc_munmap(struct v4l2_subdev *sd, void *arg)
		mregion->paddr = NULL;
	}

	if (inst->secure)
		msm_ion_unsecure_buffer(mmap->ion_client, mregion->ion_handle);

	return rc;
}

+0 −13
Original line number Diff line number Diff line
@@ -211,14 +211,6 @@ static int mdp_mmap(struct v4l2_subdev *sd, void *arg)
	}

	msm_fb_writeback_iommu_ref(inst->mdp, true);
	if (inst->secure) {
		rc = msm_ion_secure_buffer(mmap->ion_client,
			mregion->ion_handle, VIDEO_PIXEL, 0);
		if (rc) {
			WFD_MSG_ERR("Failed to secure input buffer\n");
			goto secure_fail;
		}
	}

	domain = msm_fb_get_iommu_domain(inst->mdp,
			inst->secure ? MDP_IOMMU_DOMAIN_CP :
@@ -238,9 +230,6 @@ static int mdp_mmap(struct v4l2_subdev *sd, void *arg)

	return 0;
iommu_fail:
	if (inst->secure)
		msm_ion_unsecure_buffer(mmap->ion_client, mregion->ion_handle);
secure_fail:
	msm_fb_writeback_iommu_ref(inst->mdp, false);

	return rc;
@@ -268,8 +257,6 @@ static int mdp_munmap(struct v4l2_subdev *sd, void *arg)
			mregion->ion_handle,
			domain, 0);

	if (inst->secure)
		msm_ion_unsecure_buffer(mmap->ion_client, mregion->ion_handle);
	msm_fb_writeback_iommu_ref(inst->mdp, false);

	return 0;
Loading