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

Commit a384da95 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: cpp: Call iommu detach in the error scenarios for secure case"

parents 7fa84a1a fb5236bb
Loading
Loading
Loading
Loading
+28 −4
Original line number Diff line number Diff line
@@ -878,6 +878,8 @@ static int cam_smmu_detach_device(int idx)

static int cam_smmu_attach_sec_cpp(int idx)
{
	int32_t rc = 0;

	/*
	 * When switching to secure, detach CPP NS, do scm call
	 * with CPP SID and no need of attach again, because
@@ -889,8 +891,12 @@ static int cam_smmu_attach_sec_cpp(int idx)
		return -EINVAL;
	}

	msm_camera_tz_set_mode(MSM_CAMERA_TZ_MODE_SECURE,
	rc = msm_camera_tz_set_mode(MSM_CAMERA_TZ_MODE_SECURE,
		MSM_CAMERA_TZ_HW_BLOCK_CPP);
	if (rc != 0) {
		pr_err("fail to set secure mode for cpp, rc %d", rc);
		return rc;
	}

	iommu_cb_set.cb_info[idx].state = CAM_SMMU_ATTACH;

@@ -899,8 +905,14 @@ static int cam_smmu_attach_sec_cpp(int idx)

static int cam_smmu_detach_sec_cpp(int idx)
{
	msm_camera_tz_set_mode(MSM_CAMERA_TZ_MODE_NON_SECURE,
	int32_t rc = 0;

	rc = msm_camera_tz_set_mode(MSM_CAMERA_TZ_MODE_NON_SECURE,
		MSM_CAMERA_TZ_HW_BLOCK_CPP);
	if (rc != 0) {
		pr_err("fail to switch to non secure mode for cpp, rc %d", rc);
		return rc;
	}

	iommu_cb_set.cb_info[idx].state = CAM_SMMU_DETACH;

@@ -917,6 +929,8 @@ static int cam_smmu_detach_sec_cpp(int idx)

static int cam_smmu_attach_sec_vfe_ns_stats(int idx)
{
	int32_t rc = 0;

	/*
	 *When switching to secure, for secure pixel and non-secure stats
	 *localizing scm/attach of non-secure SID's in attach secure
@@ -933,16 +947,26 @@ static int cam_smmu_attach_sec_vfe_ns_stats(int idx)
		}
	}

	msm_camera_tz_set_mode(MSM_CAMERA_TZ_MODE_SECURE,
	rc = msm_camera_tz_set_mode(MSM_CAMERA_TZ_MODE_SECURE,
		MSM_CAMERA_TZ_HW_BLOCK_ISP);
	if (rc != 0) {
		pr_err("fail to set secure mode for vfe, rc %d", rc);
		return rc;
	}

	return 0;
}

static int cam_smmu_detach_sec_vfe_ns_stats(int idx)
{
	msm_camera_tz_set_mode(MSM_CAMERA_TZ_MODE_NON_SECURE,
	int32_t rc = 0;

	rc = msm_camera_tz_set_mode(MSM_CAMERA_TZ_MODE_NON_SECURE,
		MSM_CAMERA_TZ_HW_BLOCK_ISP);
	if (rc != 0) {
		pr_err("fail to switch to non secure mode for vfe, rc %d", rc);
		return rc;
	}

	/*
	 *While exiting from secure mode for secure pixel and non-secure stats,
+13 −3
Original line number Diff line number Diff line
@@ -834,8 +834,10 @@ static int cpp_init_mem(struct cpp_device *cpp_dev)
	else
		rc = cam_smmu_get_handle("cpp", &iommu_hdl);

	if (rc < 0)
	if (rc < 0) {
		pr_err("smmu get handle failed\n");
		return -ENODEV;
	}

	cpp_dev->iommu_hdl = iommu_hdl;
	cam_smmu_reg_client_page_fault_handler(
@@ -1466,10 +1468,16 @@ static int cpp_close_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
		msm_cpp_clear_timer(cpp_dev);
		cpp_release_hardware(cpp_dev);
		if (cpp_dev->iommu_state == CPP_IOMMU_STATE_ATTACHED) {
			cpp_dev->iommu_state = CPP_IOMMU_STATE_DETACHED;
			rc = cam_smmu_ops(cpp_dev->iommu_hdl, CAM_SMMU_DETACH);
			if (cpp_dev->security_mode == SECURE_MODE)
				rc = cam_smmu_ops(cpp_dev->iommu_hdl,
					CAM_SMMU_DETACH_SEC_CPP);
			else
				rc = cam_smmu_ops(cpp_dev->iommu_hdl,
					CAM_SMMU_DETACH);

			if (rc < 0)
				pr_err("Error: Detach fail in release\n");
			cpp_dev->iommu_state = CPP_IOMMU_STATE_DETACHED;
		}
		cam_smmu_destroy_handle(cpp_dev->iommu_hdl);
		msm_cpp_empty_list(processing_q, list_frame);
@@ -3450,6 +3458,7 @@ STREAM_BUFF_END:
			rc = msm_cpp_copy_from_ioctl_ptr(&cpp_attach_info,
				ioctl_ptr);
			if (rc < 0) {
				pr_err("CPP_IOMMU_ATTACH copy from user fail");
				ERR_COPY_FROM_USER();
				return -EINVAL;
			}
@@ -3487,6 +3496,7 @@ STREAM_BUFF_END:
			rc = msm_cpp_copy_from_ioctl_ptr(&cpp_attach_info,
				ioctl_ptr);
			if (rc < 0) {
				pr_err("CPP_IOMMU_DETTACH copy from user fail");
				ERR_COPY_FROM_USER();
				return -EINVAL;
			}