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

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

msm: camera: isp: Protect access to module_cfg register with lock



For vfe 40 and 44, frame modules and stats modules are enabled
by bits in same register. These are enabled from 2 different
contexts. Hence need to protect the access to this register with
lock to avoid race condition.

Change-Id: Ie066bb3317c26d2c62bcfb34cbf270d913b6205d
Signed-off-by: default avatarHarsh Shah <harshs@codeaurora.org>
parent 8d8e42e4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -197,6 +197,7 @@ struct msm_vfe_core_ops {
		uint32_t *irq1_mask);
	void (*get_rdi_wm_mask)(struct vfe_device *vfe_dev,
		uint32_t *rdi_wm_mask);
	bool (*is_module_cfg_lock_needed)(uint32_t reg_offset);
};
struct msm_vfe_stats_ops {
	int (*get_stats_idx)(enum msm_isp_stats_type stats_type);
+8 −0
Original line number Diff line number Diff line
@@ -1282,6 +1282,12 @@ static void msm_vfe32_stats_cfg_ub(struct vfe_device *vfe_dev)
	return;
}

static bool msm_vfe32_is_module_cfg_lock_needed(
	uint32_t reg_offset)
{
	return false;
}

static void msm_vfe32_stats_enable_module(struct vfe_device *vfe_dev,
	uint32_t stats_mask, uint8_t enable)
{
@@ -1503,6 +1509,8 @@ struct msm_vfe_hardware_info vfe32_hw_info = {
			.get_error_mask = msm_vfe32_get_error_mask,
			.process_error_status = msm_vfe32_process_error_status,
			.get_overflow_mask = msm_vfe32_get_overflow_mask,
			.is_module_cfg_lock_needed =
				msm_vfe32_is_module_cfg_lock_needed,
		},
		.stats_ops = {
			.get_stats_idx = msm_vfe32_get_stats_idx,
+18 −0
Original line number Diff line number Diff line
@@ -1904,11 +1904,21 @@ static void msm_vfe40_stats_update_cgc_override(struct vfe_device *vfe_dev,
	msm_camera_io_w(module_cfg, vfe_dev->vfe_base + 0x974);
}

static bool msm_vfe40_is_module_cfg_lock_needed(
	uint32_t reg_offset)
{
	if (reg_offset == 0x18)
		return true;
	else
		return false;
}

static void msm_vfe40_stats_enable_module(struct vfe_device *vfe_dev,
	uint32_t stats_mask, uint8_t enable)
{
	int i;
	uint32_t module_cfg, module_cfg_mask = 0;
	unsigned long flags;

	for (i = 0; i < VFE40_NUM_STATS_TYPE; i++) {
		if ((stats_mask >> i) & 0x1) {
@@ -1934,12 +1944,18 @@ static void msm_vfe40_stats_enable_module(struct vfe_device *vfe_dev,
		}
	}

	/*
	 * For vfe40 stats and other modules share module_cfg register.
	 * Hence need to Grab lock.
	 */
	spin_lock_irqsave(&vfe_dev->shared_data_lock, flags);
	module_cfg = msm_camera_io_r(vfe_dev->vfe_base + 0x18);
	if (enable)
		module_cfg |= module_cfg_mask;
	else
		module_cfg &= ~module_cfg_mask;
	msm_camera_io_w(module_cfg, vfe_dev->vfe_base + 0x18);
	spin_unlock_irqrestore(&vfe_dev->shared_data_lock, flags);
}

static void msm_vfe40_stats_update_ping_pong_addr(
@@ -2151,6 +2167,8 @@ struct msm_vfe_hardware_info vfe40_hw_info = {
			.get_halt_restart_mask =
				msm_vfe40_get_halt_restart_mask,
			.process_error_status = msm_vfe40_process_error_status,
			.is_module_cfg_lock_needed =
				msm_vfe40_is_module_cfg_lock_needed,
		},
		.stats_ops = {
			.get_stats_idx = msm_vfe40_get_stats_idx,
+18 −0
Original line number Diff line number Diff line
@@ -1644,12 +1644,22 @@ static void msm_vfe44_stats_cfg_ub(struct vfe_device *vfe_dev)
	}
}

static bool msm_vfe44_is_module_cfg_lock_needed(
	uint32_t reg_offset)
{
	if (reg_offset == 0x18)
		return true;
	else
		return false;
}

static void msm_vfe44_stats_enable_module(struct vfe_device *vfe_dev,
	uint32_t stats_mask, uint8_t enable)
{
	int i;
	uint32_t module_cfg, module_cfg_mask = 0;
	uint32_t stats_cfg, stats_cfg_mask = 0;
	unsigned long flags;

	for (i = 0; i < VFE44_NUM_STATS_TYPE; i++) {
		if ((stats_mask >> i) & 0x1) {
@@ -1678,12 +1688,18 @@ static void msm_vfe44_stats_enable_module(struct vfe_device *vfe_dev,
		}
	}

	/*
	 * For vfe44 stats and other modules share module_cfg register.
	 * Hence need to Grab lock.
	 */
	spin_lock_irqsave(&vfe_dev->shared_data_lock, flags);
	module_cfg = msm_camera_io_r(vfe_dev->vfe_base + 0x18);
	if (enable)
		module_cfg |= module_cfg_mask;
	else
		module_cfg &= ~module_cfg_mask;
	msm_camera_io_w(module_cfg, vfe_dev->vfe_base + 0x18);
	spin_unlock_irqrestore(&vfe_dev->shared_data_lock, flags);

	stats_cfg = msm_camera_io_r(vfe_dev->vfe_base + 0x888);
	if (enable)
@@ -1955,6 +1971,8 @@ struct msm_vfe_hardware_info vfe44_hw_info = {
			.get_halt_restart_mask =
				msm_vfe44_get_halt_restart_mask,
			.process_error_status = msm_vfe44_process_error_status,
			.is_module_cfg_lock_needed =
				msm_vfe44_is_module_cfg_lock_needed,
		},
		.stats_ops = {
			.get_stats_idx = msm_vfe44_get_stats_idx,
+8 −0
Original line number Diff line number Diff line
@@ -1773,6 +1773,12 @@ static void msm_vfe46_stats_update_cgc_override(struct vfe_device *vfe_dev,
	msm_camera_io_w(module_cfg, vfe_dev->vfe_base + 0x30);
}

static bool msm_vfe46_is_module_cfg_lock_needed(
	uint32_t reg_offset)
{
	return false;
}

static void msm_vfe46_stats_enable_module(struct vfe_device *vfe_dev,
	uint32_t stats_mask, uint8_t enable)
{
@@ -2042,6 +2048,8 @@ struct msm_vfe_hardware_info vfe46_hw_info = {
			.get_halt_restart_mask =
				msm_vfe46_get_halt_restart_mask,
			.process_error_status = msm_vfe46_process_error_status,
			.is_module_cfg_lock_needed =
				msm_vfe46_is_module_cfg_lock_needed,
		},
		.stats_ops = {
			.get_stats_idx = msm_vfe46_get_stats_idx,
Loading