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

Commit d06cd285 authored by Terence Ho's avatar Terence Ho
Browse files

msm: ais: add support for nested smmu



Add support for nested camera smmu for content protected streams.

Acked-by: default avatarAbderahmane Allalou <aallalou@qti.qualcomm.com&gt;.>

Change-Id: I84535d826e6b4657277fb6b48326d7d28a3ab93b
Signed-off-by: default avatarTerence Ho <terenceh@codeaurora.org>
parent 1788fd25
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -498,7 +498,8 @@ static void ais_ife_dev_iommu_fault_handler(

	p_ife_dev = (struct ais_ife_dev *)token;

	CAM_ERR(CAM_ISP, "IFE%d Pagefault at %lu", p_ife_dev->hw_idx, iova);
	CAM_ERR(CAM_ISP, "IFE%d Pagefault at iova 0x%x %s",
		p_ife_dev->hw_idx, iova, domain->name);
}

static int ais_ife_dev_remove(struct platform_device *pdev)
@@ -549,7 +550,6 @@ static int ais_ife_dev_probe(struct platform_device *pdev)
	}

	mutex_init(&p_ife_dev->mutex);
	spin_lock_init(&p_ife_dev->eventq_lock);

	/*
	 *  for now, we only support one iommu handle. later
@@ -571,13 +571,19 @@ static int ais_ife_dev_probe(struct platform_device *pdev)
		goto attach_fail;
	}

	rc = cam_smmu_get_handle("cam-secure",
	rc = cam_smmu_get_handle("ife-cp",
		&p_ife_dev->iommu_hdl_secure);
	if (rc) {
		CAM_ERR(CAM_ISP, "Failed to get secure iommu handle %d", rc);
		goto secure_fail;
	}

	rc = cam_smmu_ops(p_ife_dev->iommu_hdl_secure, CAM_SMMU_ATTACH);
	if (rc && rc != -EALREADY) {
		CAM_ERR(CAM_ISP, "Attach secure iommu handle failed %d", rc);
		goto secure_fail;
	}

	CAM_DBG(CAM_ISP, "iommu_handles: non-secure[0x%x], secure[0x%x]",
		p_ife_dev->iommu_hdl,
		p_ife_dev->iommu_hdl_secure);
@@ -585,6 +591,9 @@ static int ais_ife_dev_probe(struct platform_device *pdev)
	cam_smmu_set_client_page_fault_handler(p_ife_dev->iommu_hdl,
			ais_ife_dev_iommu_fault_handler, p_ife_dev);

	cam_smmu_set_client_page_fault_handler(p_ife_dev->iommu_hdl_secure,
			ais_ife_dev_iommu_fault_handler, p_ife_dev);

	hw_init.hw_idx = p_ife_dev->hw_idx;
	hw_init.iommu_hdl = p_ife_dev->iommu_hdl;
	hw_init.iommu_hdl_secure = p_ife_dev->iommu_hdl_secure;
@@ -594,14 +603,14 @@ static int ais_ife_dev_probe(struct platform_device *pdev)
	rc = ais_ife_csid_hw_init(&p_ife_dev->p_csid_drv, &hw_init);
	if (rc) {
		CAM_ERR(CAM_ISP, "IFE%d no CSID dev", p_ife_dev->hw_idx, rc);
		goto secure_fail;
		goto secure_attach_fail;
	}

	rc = ais_vfe_hw_init(&p_ife_dev->p_vfe_drv, &hw_init,
			p_ife_dev->p_csid_drv);
	if (rc) {
		CAM_ERR(CAM_ISP, "IFE%d no VFE dev", p_ife_dev->hw_idx, rc);
		goto secure_fail;
		goto secure_attach_fail;
	}

	CAM_INFO(CAM_ISP, "IFE%d probe complete", p_ife_dev->hw_idx);
@@ -610,6 +619,9 @@ static int ais_ife_dev_probe(struct platform_device *pdev)

	return 0;

secure_attach_fail:
	cam_smmu_ops(p_ife_dev->iommu_hdl_secure,
		CAM_SMMU_DETACH);
secure_fail:
	cam_smmu_ops(p_ife_dev->iommu_hdl,
		CAM_SMMU_DETACH);
+0 −1
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ struct ais_ife_dev {
	int iommu_hdl;
	int iommu_hdl_secure;

	spinlock_t eventq_lock;
	struct mutex mutex;
	int32_t open_cnt;
};
+8 −2
Original line number Diff line number Diff line
@@ -438,6 +438,8 @@ int ais_vfe_reserve(void *hw_priv, void *reserve_args, uint32_t arg_size)
		goto EXIT;
	}

	rdi_path->secure_mode = rdi_cfg->out_cfg.secure_mode;

	cam_io_w(0xf, core_info->mem_base + client_regs->burst_limit);
	/*disable pack as it is done in CSID*/
	cam_io_w(0x0, core_info->mem_base + client_regs->packer_cfg);
@@ -766,8 +768,11 @@ static int ais_vfe_cmd_enq_buf(struct ais_vfe_hw_core_info *core_info,
	vfe_buf->bufIdx = enq_buf->buffer.idx;
	vfe_buf->mem_handle = enq_buf->buffer.mem_handle;

	mmu_hdl = cam_mem_is_secure_buf(vfe_buf->mem_handle) ?
			core_info->iommu_hdl_secure : core_info->iommu_hdl;
	mmu_hdl = core_info->iommu_hdl;

	if (cam_mem_is_secure_buf(vfe_buf->mem_handle) || rdi_path->secure_mode)
		mmu_hdl = core_info->iommu_hdl_secure;

	rc = cam_mem_get_io_buf(vfe_buf->mem_handle,
		mmu_hdl, &vfe_buf->iova_addr, &src_buf_size);
	if (rc < 0) {
@@ -1098,6 +1103,7 @@ static int ais_vfe_handle_error(
			continue;

		p_rdi = &core_info->rdi_out[path];

		if (p_rdi->state != AIS_ISP_RESOURCE_STATE_STREAMING)
			continue;

+1 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ struct ais_vfe_rdi_output {
	enum ais_isp_resource_state      state;

	uint32_t                         en_cfg;
	uint32_t                         secure_mode;

	spinlock_t                       buffer_lock;
	struct ais_vfe_buffer_t          buffers[AIS_VFE_MAX_BUF];
+11 −5
Original line number Diff line number Diff line
/* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -217,6 +217,7 @@ int cam_mem_get_io_buf(int32_t buf_handle, int32_t mmu_handle,
			tbl.bufq[idx].fd,
			iova_ptr,
			len_ptr);

	if (rc) {
		CAM_ERR(CAM_MEM,
			"fail to map buf_hdl:0x%x, mmu_hdl: 0x%x for fd:%d",
@@ -511,6 +512,9 @@ static int cam_mem_util_ion_alloc(struct cam_mem_mgr_alloc_cmd *cmd,
	} else if (cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE) {
		heap_id = ION_HEAP(ION_SECURE_DISPLAY_HEAP_ID);
		ion_flag |= ION_FLAG_SECURE | ION_FLAG_CP_CAMERA;
	} else if (cmd->flags & CAM_MEM_FLAG_CP_PIXEL) {
		heap_id = ION_HEAP(ION_SECURE_HEAP_ID);
		ion_flag |= ION_FLAG_SECURE | ION_FLAG_CP_PIXEL;
	} else {
		heap_id = ION_HEAP(ION_SYSTEM_HEAP_ID) |
			ION_HEAP(ION_CAMERA_HEAP_ID);
@@ -540,8 +544,9 @@ static int cam_mem_util_check_alloc_flags(struct cam_mem_mgr_alloc_cmd *cmd)
		return -EINVAL;
	}

	if (cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE &&
		cmd->flags & CAM_MEM_FLAG_KMD_ACCESS) {
	if (((cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE) ||
			(cmd->flags & CAM_MEM_FLAG_CP_PIXEL)) &&
		(cmd->flags & CAM_MEM_FLAG_KMD_ACCESS)) {
		CAM_ERR(CAM_MEM, "Kernel mapping in secure mode not allowed");
		return -EINVAL;
	}
@@ -562,8 +567,9 @@ static int cam_mem_util_check_map_flags(struct cam_mem_mgr_map_cmd *cmd)
		return -EINVAL;
	}

	if (cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE &&
		cmd->flags & CAM_MEM_FLAG_KMD_ACCESS) {
	if (((cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE) ||
			(cmd->flags & CAM_MEM_FLAG_CP_PIXEL)) &&
		(cmd->flags & CAM_MEM_FLAG_KMD_ACCESS)) {
		CAM_ERR(CAM_MEM,
			"Kernel mapping in secure mode not allowed, flags=0x%x",
			cmd->flags);
Loading