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

Commit 3a2dd1f7 authored by Shadul Shaikh's avatar Shadul Shaikh Committed by Gerrit - the friendly Code Review server
Browse files

msm: camera: Unmap secure buffers in secure camera use case



Dettach and unmap DMA buffers obtained previously from DMA attach
and mappings respectively.

Change-Id: I1f74afb791b2bd37cb7d6733400444d8c86e7717
Signed-off-by: default avatarShadul Shaikh <sshadu@codeaurora.org>
parent 5ddc46af
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -149,6 +149,8 @@ struct cam_dma_buff_info {

struct cam_sec_buff_info {
	struct dma_buf *dmabuf;
	struct dma_buf_attachment *attach;
	struct sg_table *table;
	enum dma_data_direction dir;
	int ref_count;
	dma_addr_t paddr;
@@ -1662,11 +1664,27 @@ static int cam_smmu_secure_unmap_buf_and_remove_from_list(
		struct cam_sec_buff_info *mapping_info,
		int idx)
{
	if (!mapping_info) {
		pr_err("Error: List doesn't exist\n");
	if ((!mapping_info->dmabuf) || (!mapping_info->table) ||
		(!mapping_info->attach)) {
		pr_err("Error: Invalid params dev = %pK, table = %pK",
			(void *)iommu_cb_set.cb_info[idx].dev,
			(void *)mapping_info->table);
		pr_err("Error:dma_buf = %pK, attach = %pK\n",
			(void *)mapping_info->dmabuf,
			(void *)mapping_info->attach);
		return -EINVAL;
	}

	/* skip cache operations */
	mapping_info->attach->dma_map_attrs |= DMA_ATTR_SKIP_CPU_SYNC;

	/* iommu buffer clean up */
	dma_buf_unmap_attachment(mapping_info->attach,
	mapping_info->table, mapping_info->dir);
	dma_buf_detach(mapping_info->dmabuf, mapping_info->attach);
	dma_buf_put(mapping_info->dmabuf);
	mapping_info->dmabuf = NULL;

	list_del_init(&mapping_info->list);

	/* free one buffer */
@@ -1786,6 +1804,8 @@ static int cam_smmu_map_stage2_buffer_and_add_to_list(int idx, int ion_fd,
	mapping_info->dir = dma_dir;
	mapping_info->ref_count = 1;
	mapping_info->dmabuf = dmabuf;
	mapping_info->attach = attach;
	mapping_info->table = table;

	CDBG("ion_fd = %d, dev = %pK, paddr= %pK, len = %u\n", ion_fd,
			(void *)iommu_cb_set.cb_info[idx].dev,