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

Commit 7eafa4d1 authored by Harsh Shah's avatar Harsh Shah
Browse files

msm: camera: isp: Add ref count to attach to smmu only once



VFE as a client should attach to smmu driver only once. Add ref_cnt
to prevent additional attach.

Change-Id: I03e24fe3872661d9ae91645a2f80530134e0069d
Signed-off-by: default avatarHarsh Shah <harshs@codeaurora.org>
parent f1d461b6
Loading
Loading
Loading
Loading
+28 −16
Original line number Diff line number Diff line
@@ -1082,27 +1082,39 @@ int msm_isp_smmu_attach(struct msm_isp_buf_mgr *buf_mgr,
		 * Call hypervisor thru scm call to notify secure or
		 * non-secure mode
		 */

		rc = cam_smmu_ops(buf_mgr->img_iommu_hdl, CAM_SMMU_ATTACH);
		if (buf_mgr->attach_ref_cnt == 0) {
			rc = cam_smmu_ops(buf_mgr->img_iommu_hdl,
				CAM_SMMU_ATTACH);
			if (rc < 0) {
				pr_err("%s: img smmu attach error, rc :%d\n",
					__func__, rc);
			goto err1;
			}
		rc = cam_smmu_ops(buf_mgr->stats_iommu_hdl, CAM_SMMU_ATTACH);
			rc = cam_smmu_ops(buf_mgr->stats_iommu_hdl,
				CAM_SMMU_ATTACH);
			if (rc < 0) {
				pr_err("%s: stats smmu attach error, rc :%d\n",
					__func__, rc);
				goto err2;
			}
		}
		buf_mgr->attach_ref_cnt++;
	} else {
		rc = cam_smmu_ops(buf_mgr->img_iommu_hdl, CAM_SMMU_DETACH);
		rc |= cam_smmu_ops(buf_mgr->stats_iommu_hdl, CAM_SMMU_DETACH);
		if (buf_mgr->attach_ref_cnt == 1) {
			rc = cam_smmu_ops(buf_mgr->img_iommu_hdl,
				CAM_SMMU_DETACH);
			rc |= cam_smmu_ops(buf_mgr->stats_iommu_hdl,
				CAM_SMMU_DETACH);
			if (rc < 0) {
				pr_err("%s: img/stats smmu detach error, rc :%d\n",
					__func__, rc);
			}
		}
		if (buf_mgr->attach_ref_cnt > 0)
			buf_mgr->attach_ref_cnt--;
		else
			pr_err("%s: Error! Invalid ref_cnt\n", __func__);
	}
	mutex_unlock(&buf_mgr->lock);
	return rc;

+1 −1
Original line number Diff line number Diff line
@@ -184,7 +184,7 @@ struct msm_isp_buf_mgr {
	int num_iommu_ctx;
	struct list_head buffer_q;
	int num_iommu_secure_ctx;
	int attach_ref_cnt[MAX_PROTECTION_MODE][MAX_IOMMU_CTX];
	int attach_ref_cnt;
	enum msm_isp_buf_mgr_state attach_state;
	struct device *isp_dev;
	struct mutex lock;