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

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

msm: camera: isp: Prevent locking same spin_lock twice



The shared_data_lock is used to protect the stream_update count
variable and also the stats enable function. Reduce scope of
lock to only protected variable instead of entire method so that
both places can grab lock without resource conflict.

Change-Id: I1c4d44e6bfa2de73a424df1deda0667416190a1b
Signed-off-by: default avatarHarsh Shah <harshs@codeaurora.org>
parent d3846f3c
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -971,7 +971,6 @@ void msm_isp_axi_stream_update(struct vfe_device *vfe_dev,
	unsigned long flags;
	unsigned long flags;
	struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
	struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;


	spin_lock_irqsave(&vfe_dev->shared_data_lock, flags);
	for (i = 0; i < MAX_NUM_STREAM; i++) {
	for (i = 0; i < MAX_NUM_STREAM; i++) {
		if (SRC_TO_INTF(axi_data->stream_info[i].stream_src) !=
		if (SRC_TO_INTF(axi_data->stream_info[i].stream_src) !=
			frame_src) {
			frame_src) {
@@ -998,9 +997,11 @@ void msm_isp_axi_stream_update(struct vfe_device *vfe_dev,
		}
		}
	}
	}


	spin_lock_irqsave(&vfe_dev->shared_data_lock, flags);
	if (vfe_dev->axi_data.stream_update[frame_src]) {
	if (vfe_dev->axi_data.stream_update[frame_src]) {
		vfe_dev->axi_data.stream_update[frame_src]--;
		vfe_dev->axi_data.stream_update[frame_src]--;
	}
	}
	spin_unlock_irqrestore(&vfe_dev->shared_data_lock, flags);


	if (vfe_dev->axi_data.pipeline_update == DISABLE_CAMIF ||
	if (vfe_dev->axi_data.pipeline_update == DISABLE_CAMIF ||
		(vfe_dev->axi_data.pipeline_update ==
		(vfe_dev->axi_data.pipeline_update ==
@@ -1012,8 +1013,6 @@ void msm_isp_axi_stream_update(struct vfe_device *vfe_dev,


	if (vfe_dev->axi_data.stream_update[frame_src] == 0)
	if (vfe_dev->axi_data.stream_update[frame_src] == 0)
		complete(&vfe_dev->stream_config_complete);
		complete(&vfe_dev->stream_config_complete);

	spin_unlock_irqrestore(&vfe_dev->shared_data_lock, flags);
}
}


static void msm_isp_reload_ping_pong_offset(struct vfe_device *vfe_dev,
static void msm_isp_reload_ping_pong_offset(struct vfe_device *vfe_dev,
@@ -1647,8 +1646,13 @@ static int msm_isp_axi_wait_for_cfg_done(struct vfe_device *vfe_dev,
		msecs_to_jiffies(VFE_MAX_CFG_TIMEOUT));
		msecs_to_jiffies(VFE_MAX_CFG_TIMEOUT));
	if (rc == 0) {
	if (rc == 0) {
		for (i = 0; i < VFE_SRC_MAX; i++) {
		for (i = 0; i < VFE_SRC_MAX; i++) {
			if (src_mask & (1 << i))
			if (src_mask & (1 << i)) {
				spin_lock_irqsave(&vfe_dev->shared_data_lock,
					flags);
				vfe_dev->axi_data.stream_update[i] = 0;
				vfe_dev->axi_data.stream_update[i] = 0;
				spin_unlock_irqrestore(&vfe_dev->
					shared_data_lock, flags);
			}
		}
		}
		pr_err("%s: wait timeout\n", __func__);
		pr_err("%s: wait timeout\n", __func__);
		rc = -EBUSY;
		rc = -EBUSY;