diff --git a/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c b/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c index e5342bd95163..6f25c913b352 100644 --- a/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c +++ b/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c @@ -2648,6 +2648,7 @@ static int cam_tfe_mgr_config_hw(void *hw_mgr_priv, struct cam_tfe_hw_mgr_ctx *ctx; struct cam_isp_prepare_hw_update_data *hw_update_data; bool cdm_hang_detect = false; + unsigned long rem_jiffies = 0; if (!hw_mgr_priv || !config_hw_args) { CAM_ERR(CAM_ISP, "Invalid arguments"); @@ -2814,12 +2815,13 @@ static int cam_tfe_mgr_config_hw(void *hw_mgr_priv, goto end; for (i = 0; i < CAM_TFE_HW_CONFIG_WAIT_MAX_TRY; i++) { - rc = wait_for_completion_timeout( + rem_jiffies = wait_for_completion_timeout( &ctx->config_done_complete, msecs_to_jiffies( CAM_TFE_HW_CONFIG_TIMEOUT)); - if (rc <= 0) { - if (!cam_cdm_detect_hang_error(ctx->cdm_handle)) { + if (rem_jiffies <= 0) { + rc = cam_cdm_detect_hang_error(ctx->cdm_handle); + if (rc == 0) { CAM_ERR(CAM_ISP, "CDM workqueue delay detected, wait for some more time req_id=%llu rc=%d ctx_index %d", cfg->request_id, rc, @@ -2831,24 +2833,19 @@ static int cam_tfe_mgr_config_hw(void *hw_mgr_priv, CAM_DEFAULT_VALUE, CAM_DEFAULT_VALUE, rc); continue; - } - - CAM_ERR(CAM_ISP, - "config done completion timeout for req_id=%llu rc=%d ctx_index %d", - cfg->request_id, rc, - ctx->ctx_index); - - cam_req_mgr_debug_delay_detect(); - trace_cam_delay_detect("ISP", - "config done completion timeout", - cfg->request_id, ctx->ctx_index, - CAM_DEFAULT_VALUE, CAM_DEFAULT_VALUE, - rc); - - if (rc == 0) + } else { + CAM_ERR(CAM_ISP, + "config done completion timeout, cdm_hang=%d on req_id=%llu ctx_index %d", + true, cfg->request_id, ctx->ctx_index); + cam_req_mgr_debug_delay_detect(); + trace_cam_delay_detect("ISP", + "config done completion timeout", + cfg->request_id, ctx->ctx_index, + CAM_DEFAULT_VALUE, CAM_DEFAULT_VALUE, + rc); rc = -ETIMEDOUT; - - goto end; + break; + } } else { rc = 0; CAM_DBG(CAM_ISP, @@ -2859,7 +2856,8 @@ static int cam_tfe_mgr_config_hw(void *hw_mgr_priv, } if ((i == CAM_TFE_HW_CONFIG_WAIT_MAX_TRY) && (rc == 0)) - rc = -ETIMEDOUT; + CAM_DBG(CAM_ISP, + "Wq delayed but IRQ CDM done"); end: CAM_DBG(CAM_ISP, "Exit: Config Done: %llu", cfg->request_id); diff --git a/drivers/cam_ope/cam_ope_context.c b/drivers/cam_ope/cam_ope_context.c index c8be0da353d4..de93c02a0eab 100644 --- a/drivers/cam_ope/cam_ope_context.c +++ b/drivers/cam_ope/cam_ope_context.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -39,7 +40,6 @@ static int cam_ope_context_dump_active_request(void *data, return -EINVAL; } - mutex_lock(&ctx->ctx_mutex); if (ctx->state < CAM_CTX_ACQUIRED || ctx->state > CAM_CTX_ACTIVATED) { CAM_ERR(CAM_OPE, "Invalid state ope ctx %d state %d", ctx->ctx_id, ctx->state); @@ -65,7 +65,6 @@ static int cam_ope_context_dump_active_request(void *data, } end: - mutex_unlock(&ctx->ctx_mutex); return rc; } diff --git a/drivers/cam_req_mgr/cam_mem_mgr.c b/drivers/cam_req_mgr/cam_mem_mgr.c index 369f6639638f..2cf85ed77136 100644 --- a/drivers/cam_req_mgr/cam_mem_mgr.c +++ b/drivers/cam_req_mgr/cam_mem_mgr.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. - * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -438,7 +438,6 @@ static int cam_mem_util_get_dma_buf_fd(size_t len, struct dma_buf **buf, int *fd) { - struct dma_buf *dmabuf = NULL; int rc = 0; struct timespec64 ts1, ts2; long microsec = 0; @@ -457,6 +456,12 @@ static int cam_mem_util_get_dma_buf_fd(size_t len, *buf = ion_alloc(len, heap_id_mask, flags); if (IS_ERR_OR_NULL(*buf)) return -ENOMEM; + /* + * increment the ref count so that ref count becomes 2 here + * when we close fd, refcount becomes 1 and when we do + * dmap_put_buf, ref count becomes 0 and memory will be freed. + */ + get_dma_buf(*buf); *fd = dma_buf_fd(*buf, O_CLOEXEC); if (*fd < 0) { @@ -465,17 +470,6 @@ static int cam_mem_util_get_dma_buf_fd(size_t len, goto get_fd_fail; } - /* - * increment the ref count so that ref count becomes 2 here - * when we close fd, refcount becomes 1 and when we do - * dmap_put_buf, ref count becomes 0 and memory will be freed. - */ - dmabuf = dma_buf_get(*fd); - if (IS_ERR_OR_NULL(dmabuf)) { - CAM_ERR(CAM_MEM, "dma_buf_get failed, *fd=%d", *fd); - rc = -EINVAL; - } - if (tbl.alloc_profile_enable) { CAM_GET_TIMESTAMP(ts2); CAM_GET_TIMESTAMP_DIFF_IN_MICRO(ts1, ts2, microsec);