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

Commit 2434c2e1 authored by Harsh Shah's avatar Harsh Shah Committed by Gerrit - the friendly Code Review server
Browse files

msm: camera: isp: Move the lock to executing function



Move the lock responsibility from calling method to the place
where the mutually exclusive code executes. This will prevent
potential errors of unprotected calls from calling places.

Change-Id: Ibdd7080774ff686b4fc96d1d2d020564b367b79a
Signed-off-by: default avatarHarsh Shah <harshs@codeaurora.org>
parent c312a53c
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -672,6 +672,7 @@ static int msm_isp_update_put_buf_cnt(struct msm_isp_buf_mgr *buf_mgr,
	struct msm_isp_bufq *bufq = NULL;
	struct msm_isp_buffer *buf_info = NULL;
	enum msm_isp_buffer_state state;
	unsigned long flags;

	bufq = msm_isp_get_bufq(buf_mgr, bufq_handle);
	if (!bufq) {
@@ -685,6 +686,7 @@ static int msm_isp_update_put_buf_cnt(struct msm_isp_buf_mgr *buf_mgr,
		return rc;
	}

	spin_lock_irqsave(&bufq->bufq_lock, flags);
	if (bufq->buf_type != ISP_SHARE_BUF ||
		buf_info->buf_put_count == 0) {
		buf_info->frame_id = frame_id;
@@ -697,12 +699,14 @@ static int msm_isp_update_put_buf_cnt(struct msm_isp_buf_mgr *buf_mgr,
			buf_info->buf_put_count++;
			if (buf_info->buf_put_count != ISP_SHARE_BUF_CLIENT) {
				rc = buf_info->buf_put_count;
				spin_unlock_irqrestore(&bufq->bufq_lock, flags);
				return rc;
			}
		}
	} else {
		pr_warn("%s: Invalid state\n", __func__);
	}
	spin_unlock_irqrestore(&bufq->bufq_lock, flags);

	return 0;
}
@@ -817,6 +821,7 @@ static int msm_isp_buf_divert(struct msm_isp_buf_mgr *buf_mgr,
	int rc = -1;
	struct msm_isp_bufq *bufq = NULL;
	struct msm_isp_buffer *buf_info = NULL;
	unsigned long flags;

	bufq = msm_isp_get_bufq(buf_mgr, bufq_handle);
	if (!bufq) {
@@ -830,6 +835,7 @@ static int msm_isp_buf_divert(struct msm_isp_buf_mgr *buf_mgr,
		return rc;
	}

	spin_lock_irqsave(&bufq->bufq_lock, flags);
	if (bufq->buf_type != ISP_SHARE_BUF ||
		buf_info->buf_put_count == 0) {
		buf_info->frame_id = frame_id;
@@ -839,6 +845,7 @@ static int msm_isp_buf_divert(struct msm_isp_buf_mgr *buf_mgr,
		buf_info->buf_put_count++;
		if (buf_info->buf_put_count != ISP_SHARE_BUF_CLIENT) {
			rc = buf_info->buf_put_count;
			spin_unlock_irqrestore(&bufq->bufq_lock, flags);
			return rc;
		}
	}
@@ -847,6 +854,7 @@ static int msm_isp_buf_divert(struct msm_isp_buf_mgr *buf_mgr,
		buf_info->state = MSM_ISP_BUFFER_STATE_DIVERTED;
		buf_info->tv = tv;
	}
	spin_unlock_irqrestore(&bufq->bufq_lock, flags);

	return 0;
}
+0 −2
Original line number Diff line number Diff line
@@ -1268,7 +1268,6 @@ static void msm_isp_process_done_buf(struct vfe_device *vfe_dev,
		return;
	}

	spin_lock_irqsave(&buf->lock, flags);
	if (stream_info->buf_divert && rc == 0 &&
			buf_src != MSM_ISP_BUFFER_SRC_SCRATCH) {
		rc = vfe_dev->buf_mgr->ops->buf_divert(vfe_dev->buf_mgr,
@@ -1278,7 +1277,6 @@ static void msm_isp_process_done_buf(struct vfe_device *vfe_dev,
		rc = vfe_dev->buf_mgr->ops->update_put_buf_cnt(vfe_dev->buf_mgr,
			buf->bufq_handle, buf->buf_idx, frame_id);
	}
	spin_unlock_irqrestore(&buf->lock, flags);

	/* Buf divert return value represent whether the buf
	 * can be diverted. A positive return value means