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

Commit 33fc2ebd authored by Harsh Shah's avatar Harsh Shah
Browse files

msm: camera: Fix some ref count issues and race conditions



Fix issue in ref count in FD and CSIPHY HW.

Change-Id: Ia1e8304b216a747dd0c892169a888877c60fa9ed
Signed-off-by: default avatarHarsh Shah <harshs@codeaurora.org>
parent de8b7f5d
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -686,8 +686,6 @@ int cam_fd_hw_init(void *hw_priv, void *init_hw_args, uint32_t arg_size)
	fd_hw->open_count++;
	CAM_DBG(CAM_FD, "FD HW Init ref count after %d", fd_hw->open_count);

	mutex_unlock(&fd_hw->hw_mutex);

	if (init_args->ctx_hw_private) {
		struct cam_fd_ctx_hw_private *ctx_hw_private =
			init_args->ctx_hw_private;
@@ -696,10 +694,14 @@ int cam_fd_hw_init(void *hw_priv, void *init_hw_args, uint32_t arg_size)
		if (rc) {
			CAM_ERR(CAM_FD, "CDM StreamOn fail :handle=0x%x, rc=%d",
				ctx_hw_private->cdm_handle, rc);
			return rc;
			fd_hw->open_count--;
			if (!fd_hw->open_count)
				goto disable_soc;
		}
	}

	mutex_unlock(&fd_hw->hw_mutex);

	return rc;

disable_soc:
+12 −14
Original line number Diff line number Diff line
@@ -494,8 +494,8 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
	}
		break;
	case CAM_STOP_DEV: {
		if (csiphy_dev->csiphy_state !=
			CAM_CSIPHY_START) {
		if ((csiphy_dev->csiphy_state != CAM_CSIPHY_START) ||
			!csiphy_dev->start_dev_count) {
			CAM_ERR(CAM_CSIPHY, "Not in right state to stop : %d",
				csiphy_dev->csiphy_state);
			goto release_mutex;
@@ -508,16 +508,13 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
		}

		rc = cam_csiphy_disable_hw(csiphy_dev);
		if (rc < 0) {
		if (rc < 0)
			CAM_ERR(CAM_CSIPHY, "Failed in csiphy release");
			cam_cpas_stop(csiphy_dev->cpas_handle);
			goto release_mutex;
		}

		rc = cam_cpas_stop(csiphy_dev->cpas_handle);
		if (rc < 0) {
		if (rc < 0)
			CAM_ERR(CAM_CSIPHY, "de-voting CPAS: %d", rc);
			goto release_mutex;
		}

		csiphy_dev->csiphy_state = CAM_CSIPHY_ACQUIRE;
	}
		break;
@@ -547,8 +544,7 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
		} else {
			csiphy_dev->bridge_intf.device_hdl[1] = -1;
			csiphy_dev->bridge_intf.link_hdl[1] = -1;
			csiphy_dev->bridge_intf.
				session_hdl[1] = -1;
			csiphy_dev->bridge_intf.session_hdl[1] = -1;
			csiphy_dev->is_acquired_dev_combo_mode = 0;
		}

@@ -587,10 +583,10 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
		struct cam_ahb_vote ahb_vote;
		struct cam_axi_vote axi_vote;

		if (csiphy_dev->csiphy_state == CAM_CSIPHY_START) {
			csiphy_dev->start_dev_count++;

		if (csiphy_dev->csiphy_state == CAM_CSIPHY_START)
			goto release_mutex;
		}

		ahb_vote.type = CAM_VOTE_ABSOLUTE;
		ahb_vote.vote.level = CAM_SVS_VOTE;
@@ -616,9 +612,11 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,

		if (rc < 0) {
			CAM_ERR(CAM_CSIPHY, "cam_csiphy_config_dev failed");
			cam_csiphy_disable_hw(csiphy_dev);
			cam_cpas_stop(csiphy_dev->cpas_handle);
			goto release_mutex;
		}
		csiphy_dev->start_dev_count++;
		csiphy_dev->csiphy_state = CAM_CSIPHY_START;
	}
		break;