From 345ff8c6334eaf8c00905f5ef6cfeac1feff1290 Mon Sep 17 00:00:00 2001 From: Vikram Sharma Date: Mon, 17 Aug 2020 11:35:28 +0530 Subject: [PATCH] msm: camera: ope: Handle race while dumping ope req list While dumping OPE req list we were not protecting it in context mutex, this can result into unexpected behaviors. This change take care of protecting the dump logic using mutex. CRs-Fixed: 2750458 Change-Id: I916822b498cde3922274c18a06b98c898bff1d65 Signed-off-by: Vikram Sharma --- drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c b/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c index db9e760d1e15..1485e3a5eebe 100644 --- a/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c +++ b/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c @@ -43,6 +43,8 @@ static struct cam_ope_hw_mgr *ope_hw_mgr; +static int cam_ope_req_timer_reset(struct cam_ope_ctx *ctx_data); + static int cam_ope_mgr_get_rsc_idx(struct cam_ope_ctx *ctx_data, struct ope_io_buf_info *in_io_buf) { @@ -125,6 +127,8 @@ static int cam_ope_mgr_process_cmd(void *priv, void *data) if (task_data->req_id > ctx_data->last_flush_req) ctx_data->last_flush_req = 0; + cam_ope_req_timer_reset(ctx_data); + rc = cam_cdm_submit_bls(ctx_data->ope_cdm.cdm_handle, cdm_cmd); if (!rc) @@ -3639,6 +3643,7 @@ static int cam_ope_mgr_hw_dump(void *hw_priv, void *hw_dump_args) } mutex_lock(&hw_mgr->hw_mgr_mutex); + mutex_lock(&ctx_data->ctx_mutex); CAM_INFO(CAM_OPE, "Req %lld", dump_args->request_id); for (idx = 0; idx < CAM_CTX_REQ_MAX; idx++) { @@ -3652,6 +3657,7 @@ static int cam_ope_mgr_hw_dump(void *hw_priv, void *hw_dump_args) /* no matching request found */ if (idx == CAM_CTX_REQ_MAX) { + mutex_unlock(&ctx_data->ctx_mutex); mutex_unlock(&hw_mgr->hw_mgr_mutex); return 0; } @@ -3669,6 +3675,7 @@ static int cam_ope_mgr_hw_dump(void *hw_priv, void *hw_dump_args) req_ts.tv_nsec/NSEC_PER_USEC, cur_ts.tv_sec, cur_ts.tv_nsec/NSEC_PER_USEC); + mutex_unlock(&ctx_data->ctx_mutex); mutex_unlock(&hw_mgr->hw_mgr_mutex); return 0; } @@ -3680,6 +3687,7 @@ static int cam_ope_mgr_hw_dump(void *hw_priv, void *hw_dump_args) cur_ts.tv_sec, cur_ts.tv_nsec/NSEC_PER_USEC); + mutex_unlock(&ctx_data->ctx_mutex); mutex_unlock(&hw_mgr->hw_mgr_mutex); return 0; }