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

Commit fd5d3aad authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camera_v2: enable secure camera for trinket"

parents b7c05b2d 7c706f8c
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -32,6 +32,11 @@ First Level Node - CAM SMMU device
  Value type: <string>
  Definition: Should be "qcom,msm-cam-smmu".

- qcom,camera-secure-sid
  Usage: optional
  Value type: boolean
  Definition: Specifies if the sensor stream is a secure stream.

===================================================================
Second Level Node - CAM SMMU context bank device or firmware device
===================================================================
@@ -98,6 +103,7 @@ Third Level Node - CAM SMMU memory map device
Example:
	qcom,cam_smmu@0 {
		compatible = "qcom,msm-cam-smmu";
		qcom,camera-secure-sid;

		msm_cam_smmu_icp {
			compatible = "qcom,msm-cam-smmu-cb";
+1 −0
Original line number Diff line number Diff line
@@ -254,6 +254,7 @@
	qcom,cam_smmu {
		compatible = "qcom,msm-cam-smmu";
		status = "ok";
		qcom,camera-secure-sid;

		msm_cam_smmu_cb1 {
			compatible = "qcom,msm-cam-smmu-cb";
+54 −39
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ struct cam_iommu_cb_set {
	struct cam_context_bank_info *cb_info;
	u32 cb_num;
	u32 cb_init_count;
	bool camera_secure_sid;
	struct work_struct smmu_work;
	struct mutex payload_list_lock;
	struct list_head payload_list;
@@ -882,9 +883,7 @@ static int cam_smmu_attach_sec_cpp(int idx)
		 * entered the secure mode.
		 */
	}

	iommu_cb_set.cb_info[idx].state = CAM_SMMU_ATTACH;

	return 0;
}

@@ -921,6 +920,7 @@ static int cam_smmu_attach_sec_vfe_ns_stats(int idx)
{
	int32_t rc = 0;

	if (iommu_cb_set.camera_secure_sid == false) {
		/*
		 *When switching to secure, for secure pix and non-secure stats
		 *localizing scm/attach of non-secure SID's in attach secure
@@ -929,26 +929,26 @@ static int cam_smmu_attach_sec_vfe_ns_stats(int idx)
			pr_err("error: syscall failed\n");
			return -EINVAL;
		}

	}
	if (iommu_cb_set.cb_info[idx].state != CAM_SMMU_ATTACH) {
		if (cam_smmu_attach(idx)) {
			pr_err("error: failed to attach\n");
			return -EINVAL;
		}
	}

	if (iommu_cb_set.camera_secure_sid == false) {
		rc = msm_camera_tz_set_mode(MSM_CAMERA_TZ_MODE_SECURE,
			MSM_CAMERA_TZ_HW_BLOCK_ISP);
		if (rc != 0) {
		pr_err("secure mode TA notification for vfe unsuccessful, rc %d\n",
			pr_err("secure mode TA notify vfe unsuccessful rc %d\n",
				rc);
			/*
		 * Although the TA notification failed, the flow should proceed
		 * without returning an error as at this point vfe had already
		 * entered the secure mode
			 * Although the TA notification failed, the flow should
			 * proceed without returning an error as at this point
			 * vfe had already entered the secure mode
			 */
		}

	}
	return 0;
}

@@ -956,18 +956,20 @@ static int cam_smmu_detach_sec_vfe_ns_stats(int idx)
{
	int32_t rc = 0;

	if (iommu_cb_set.camera_secure_sid == false) {
		rc = msm_camera_tz_set_mode(MSM_CAMERA_TZ_MODE_NON_SECURE,
			MSM_CAMERA_TZ_HW_BLOCK_ISP);
		if (rc != 0) {
		pr_err("secure mode TA notification for vfe unsuccessful, rc %d\n",
			pr_err("secure mode TA notify vfe unsuccessful rc %d\n",
				rc);
			/*
		 * Although the TA notification failed, the flow should proceed
		 * without returning an error, as at this point vfe is in secure
		 * mode and should be switched to non-secure regardless
			 * Although the TA notification failed, the flow should
			 * proceed without returning an error, as at this point
			 * vfe is in secure mode and should be switched to
			 * non-secure regardless
			 */
		}

	}
	/*
	 *While exiting from secure mode for secure pix and non-secure stats,
	 *localizing detach/scm of non-secure SID's to detach secure
@@ -978,11 +980,12 @@ static int cam_smmu_detach_sec_vfe_ns_stats(int idx)
			return -ENODEV;
		}
	}

	if (iommu_cb_set.camera_secure_sid == false) {
		if (cam_smmu_send_syscall_pix_intf(VMID_HLOS, idx)) {
			pr_err("error: syscall failed\n");
			return -EINVAL;
		}
	}
	return 0;
}

@@ -1255,11 +1258,17 @@ int cam_smmu_ops(int handle, enum cam_smmu_ops_param ops)
		break;
	}
	case CAM_SMMU_ATTACH_SEC_CPP: {
		if (iommu_cb_set.camera_secure_sid == false)
			ret = cam_smmu_attach_sec_cpp(idx);
		else
			iommu_cb_set.cb_info[idx].state = CAM_SMMU_ATTACH;
		break;
	}
	case CAM_SMMU_DETACH_SEC_CPP: {
		if (iommu_cb_set.camera_secure_sid == false)
			ret = cam_smmu_detach_sec_cpp(idx);
		else
			iommu_cb_set.cb_info[idx].state = CAM_SMMU_DETACH;
		break;
	}
	case CAM_SMMU_VOTE:
@@ -1773,6 +1782,7 @@ static int cam_smmu_map_stage2_buffer_and_add_to_list(int idx, int ion_fd,
	mapping_info->len = *len_ptr;
	mapping_info->dir = dma_dir;
	mapping_info->ref_count = 1;
	mapping_info->dmabuf = dmabuf;

	CDBG("ion_fd = %d, dev = %pK, paddr= %pK, len = %u\n", ion_fd,
			(void *)iommu_cb_set.cb_info[idx].dev,
@@ -2239,6 +2249,11 @@ static int cam_smmu_probe(struct platform_device *pdev)
		return rc;
	}

	if (of_property_read_bool(dev->of_node, "qcom,camera-secure-sid"))
		iommu_cb_set.camera_secure_sid = true;
	else
		iommu_cb_set.camera_secure_sid = false;

	/* probe thru all the subdevices */
	rc = of_platform_populate(pdev->dev.of_node, msm_cam_smmu_dt_match,
				NULL, &pdev->dev);