msm: camera: memmgr: release buffers after usage

Call cam_mem_put_cpu_buf corresponding to
cam_mem_get_cpu_buf calls to make sure ref_cnt
is balanced and buffer is freed when all
clients are done with the buffer usage.

CRs-Fixed: 3547081
Change-Id: I9414829d6f17c368f2718fe05dbe25c71b31e674
Signed-off-by: Nirmal Abraham <quic_c_nabrah@quicinc.com>
This commit is contained in:
Nirmal Abraham 2023-07-11 16:49:51 +05:30 committed by Gerrit - the friendly Code Review server
parent f81db81382
commit 82ce65cbeb
5 changed files with 11 additions and 2 deletions

View File

@ -856,6 +856,7 @@ static int cam_hw_cdm_arb_submit_bl(struct cam_hw_info *cdm_hw,
"CDM hw bl write failed tag=%d",
core->bl_fifo[fifo_idx].bl_tag -
1);
cam_mem_put_cpu_buf(cdm_cmd->cmd[i].bl_addr.mem_handle);
list_del_init(&node->entry);
kfree(node);
return -EIO;
@ -867,11 +868,12 @@ static int cam_hw_cdm_arb_submit_bl(struct cam_hw_info *cdm_hw,
"CDM hw commit failed tag=%d",
core->bl_fifo[fifo_idx].bl_tag -
1);
cam_mem_put_cpu_buf(cdm_cmd->cmd[i].bl_addr.mem_handle);
list_del_init(&node->entry);
kfree(node);
return -EIO;
}
cam_mem_put_cpu_buf(cdm_cmd->cmd[i].bl_addr.mem_handle);
return 0;
}

View File

@ -379,6 +379,7 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
if ((len < sizeof(struct cam_packet)) ||
(cmd->offset >= (len - sizeof(struct cam_packet)))) {
CAM_ERR(CAM_CTXT, "Not enough buf");
cam_mem_put_cpu_buf((int32_t) cmd->packet_handle);
return -EINVAL;
}
@ -497,7 +498,7 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
req->in_map_entries[j].sync_id, rc);
}
}
cam_mem_put_cpu_buf((int32_t) cmd->packet_handle);
return rc;
put_ref:
for (--i; i >= 0; i--) {
@ -511,6 +512,7 @@ free_req:
req->ctx = NULL;
spin_unlock(&ctx->lock);
cam_mem_put_cpu_buf((int32_t) cmd->packet_handle);
return rc;
}

View File

@ -4936,6 +4936,7 @@ static int __cam_isp_ctx_config_dev_in_top_state(
__cam_isp_ctx_schedule_apply_req_offline(ctx_isp);
}
cam_mem_put_cpu_buf((int32_t) cmd->packet_handle);
return rc;
put_ref:
@ -4949,6 +4950,7 @@ free_req:
list_add_tail(&req->list, &ctx->free_req_list);
spin_unlock_bh(&ctx->lock);
cam_mem_put_cpu_buf((int32_t) cmd->packet_handle);
return rc;
}

View File

@ -129,6 +129,7 @@ static int cam_isp_update_dual_config(
if (dual_config->num_ports > size_isp_out) {
CAM_ERR(CAM_ISP, "num_ports %d more than max_vfe_out_res %d",
dual_config->num_ports, size_isp_out);
cam_mem_put_cpu_buf(cmd_desc->mem_handle);
return -EINVAL;
}

View File

@ -315,6 +315,7 @@ static int cam_jpeg_mgr_process_irq(void *priv, void *data)
CAM_ERR(CAM_JPEG, "Invalid offset: %u cmd buf len: %zu",
p_cfg_req->hw_cfg_args.hw_update_entries[
CAM_JPEG_PARAM].offset, cmd_buf_len);
cam_mem_put_cpu_buf(mem_hdl);
return -EINVAL;
}
@ -341,6 +342,7 @@ static int cam_jpeg_mgr_process_irq(void *priv, void *data)
mutex_lock(&g_jpeg_hw_mgr.hw_mgr_mutex);
list_add_tail(&p_cfg_req->list, &hw_mgr->free_req_list);
mutex_unlock(&g_jpeg_hw_mgr.hw_mgr_mutex);
cam_mem_put_cpu_buf(mem_hdl);
return rc;
}