msm: camera: icp: Memory leak and unused variables fixes
This change fixes some VA_UNUSED.GEN and MLK.MIGHT issues reported by KW analysis tool. In addition to a functional fix related to handle_type not being assigned properly. CRs-Fixed: 3394193 Change-Id: Id28a06f3a65c639c0968dd1858d16a547f4d4959 Signed-off-by: Atiya Kailany <quic_akailany@quicinc.com>
This commit is contained in:

committed by
Camera Software Integration

parent
a4d5454b8e
commit
fb42ce28bc
@@ -123,8 +123,6 @@ void cam_hfi_mini_dump(int client_handle, struct hfi_mini_dump_info *dst)
|
|||||||
{
|
{
|
||||||
struct hfi_info *hfi;
|
struct hfi_info *hfi;
|
||||||
struct hfi_mem_info *hfi_mem;
|
struct hfi_mem_info *hfi_mem;
|
||||||
struct hfi_qtbl *qtbl;
|
|
||||||
struct hfi_q_hdr *q_hdr;
|
|
||||||
uint32_t *dwords;
|
uint32_t *dwords;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@@ -142,12 +140,9 @@ void cam_hfi_mini_dump(int client_handle, struct hfi_mini_dump_info *dst)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qtbl = (struct hfi_qtbl *)hfi_mem->qtbl.kva;
|
|
||||||
q_hdr = &qtbl->q_hdr[Q_CMD];
|
|
||||||
dwords = (uint32_t *)hfi_mem->cmd_q.kva;
|
dwords = (uint32_t *)hfi_mem->cmd_q.kva;
|
||||||
memcpy(dst->cmd_q, dwords, ICP_CMD_Q_SIZE_IN_BYTES);
|
memcpy(dst->cmd_q, dwords, ICP_CMD_Q_SIZE_IN_BYTES);
|
||||||
|
|
||||||
q_hdr = &qtbl->q_hdr[Q_MSG];
|
|
||||||
dwords = (uint32_t *)hfi_mem->msg_q.kva;
|
dwords = (uint32_t *)hfi_mem->msg_q.kva;
|
||||||
memcpy(dst->msg_q, dwords, ICP_CMD_Q_SIZE_IN_BYTES);
|
memcpy(dst->msg_q, dwords, ICP_CMD_Q_SIZE_IN_BYTES);
|
||||||
dst->msg_q_state = hfi->msg_q_state;
|
dst->msg_q_state = hfi->msg_q_state;
|
||||||
|
@@ -1803,7 +1803,8 @@ static int cam_icp_mgr_device_resume(struct cam_icp_hw_mgr *hw_mgr,
|
|||||||
if (!dbg_prop) {
|
if (!dbg_prop) {
|
||||||
CAM_ERR(CAM_ICP, "%s Allocate command prop failed",
|
CAM_ERR(CAM_ICP, "%s Allocate command prop failed",
|
||||||
ctx_data->ctx_id_string);
|
ctx_data->ctx_id_string);
|
||||||
return -ENOMEM;
|
rc = -ENOMEM;
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbg_prop->size = size;
|
dbg_prop->size = size;
|
||||||
@@ -1822,7 +1823,8 @@ static int cam_icp_mgr_device_resume(struct cam_icp_hw_mgr *hw_mgr,
|
|||||||
default:
|
default:
|
||||||
CAM_ERR(CAM_ICP, "%s Invalid hw dev type: %u",
|
CAM_ERR(CAM_ICP, "%s Invalid hw dev type: %u",
|
||||||
ctx_data->ctx_id_string, hw_dev_type);
|
ctx_data->ctx_id_string, hw_dev_type);
|
||||||
return -EINVAL;
|
rc = -EINVAL;
|
||||||
|
goto free_dbg_prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbg_prop->prop_data[1] = hw_mgr->dev_pc_flag;
|
dbg_prop->prop_data[1] = hw_mgr->dev_pc_flag;
|
||||||
@@ -1830,6 +1832,7 @@ static int cam_icp_mgr_device_resume(struct cam_icp_hw_mgr *hw_mgr,
|
|||||||
|
|
||||||
hfi_write_cmd(hw_mgr->hfi_handle, dbg_prop);
|
hfi_write_cmd(hw_mgr->hfi_handle, dbg_prop);
|
||||||
|
|
||||||
|
free_dbg_prop:
|
||||||
kfree(dbg_prop);
|
kfree(dbg_prop);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
@@ -4528,7 +4531,6 @@ static unsigned long cam_icp_hw_mgr_mini_dump_cb(void *dst, unsigned long len,
|
|||||||
|
|
||||||
dumped_len += icp_dump_args.offset;
|
dumped_len += icp_dump_args.offset;
|
||||||
md->fw_img = (void *)icp_dump_args.cpu_addr;
|
md->fw_img = (void *)icp_dump_args.cpu_addr;
|
||||||
remain_len = len - dumped_len;
|
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
return dumped_len;
|
return dumped_len;
|
||||||
@@ -4948,7 +4950,6 @@ static int cam_icp_mgr_enqueue_config(struct cam_icp_hw_mgr *hw_mgr,
|
|||||||
uint64_t request_id = 0;
|
uint64_t request_id = 0;
|
||||||
struct crm_workq_task *task;
|
struct crm_workq_task *task;
|
||||||
struct hfi_cmd_work_data *task_data;
|
struct hfi_cmd_work_data *task_data;
|
||||||
struct hfi_cmd_dev_async *hfi_cmd;
|
|
||||||
struct cam_hw_update_entry *hw_update_entries;
|
struct cam_hw_update_entry *hw_update_entries;
|
||||||
struct icp_frame_info *frame_info = NULL;
|
struct icp_frame_info *frame_info = NULL;
|
||||||
|
|
||||||
@@ -4966,7 +4967,6 @@ static int cam_icp_mgr_enqueue_config(struct cam_icp_hw_mgr *hw_mgr,
|
|||||||
|
|
||||||
task_data = (struct hfi_cmd_work_data *)task->payload;
|
task_data = (struct hfi_cmd_work_data *)task->payload;
|
||||||
task_data->data = (void *)hw_update_entries->addr;
|
task_data->data = (void *)hw_update_entries->addr;
|
||||||
hfi_cmd = (struct hfi_cmd_dev_async *)hw_update_entries->addr;
|
|
||||||
task_data->request_id = request_id;
|
task_data->request_id = request_id;
|
||||||
task_data->type = ICP_WORKQ_TASK_CMD_TYPE;
|
task_data->type = ICP_WORKQ_TASK_CMD_TYPE;
|
||||||
task->process_cb = cam_icp_mgr_process_cmd;
|
task->process_cb = cam_icp_mgr_process_cmd;
|
||||||
@@ -5339,7 +5339,6 @@ static int cam_icp_mgr_process_cmd_desc(struct cam_icp_hw_mgr *hw_mgr,
|
|||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
int i;
|
int i;
|
||||||
int num_cmd_buf = 0;
|
|
||||||
dma_addr_t addr;
|
dma_addr_t addr;
|
||||||
size_t len;
|
size_t len;
|
||||||
struct cam_cmd_buf_desc *cmd_desc = NULL;
|
struct cam_cmd_buf_desc *cmd_desc = NULL;
|
||||||
@@ -5352,16 +5351,13 @@ static int cam_icp_mgr_process_cmd_desc(struct cam_icp_hw_mgr *hw_mgr,
|
|||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
*fw_cmd_buf_iova_addr = 0;
|
*fw_cmd_buf_iova_addr = 0;
|
||||||
for (i = 0; i < packet->num_cmd_buf; i++, num_cmd_buf++) {
|
for (i = 0; i < packet->num_cmd_buf; i++) {
|
||||||
if (cmd_desc[i].type == CAM_CMD_BUF_FW) {
|
if (cmd_desc[i].type == CAM_CMD_BUF_FW) {
|
||||||
rc = cam_mem_get_io_buf(cmd_desc[i].mem_handle,
|
rc = cam_mem_get_io_buf(cmd_desc[i].mem_handle,
|
||||||
hw_mgr->iommu_hdl, &addr, &len, NULL);
|
hw_mgr->iommu_hdl, &addr, &len, NULL);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
CAM_ERR(CAM_ICP, "%s: get cmd buf failed %x",
|
CAM_ERR(CAM_ICP, "%s: get cmd buf failed %x",
|
||||||
ctx_data->ctx_id_string, hw_mgr->iommu_hdl);
|
ctx_data->ctx_id_string, hw_mgr->iommu_hdl);
|
||||||
|
|
||||||
if (num_cmd_buf > 0)
|
|
||||||
num_cmd_buf--;
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
/* FW buffers are expected to be within 32-bit address range */
|
/* FW buffers are expected to be within 32-bit address range */
|
||||||
@@ -5385,9 +5381,6 @@ static int cam_icp_mgr_process_cmd_desc(struct cam_icp_hw_mgr *hw_mgr,
|
|||||||
CAM_ERR(CAM_ICP, "%s: get cmd buf failed %x",
|
CAM_ERR(CAM_ICP, "%s: get cmd buf failed %x",
|
||||||
ctx_data->ctx_id_string, hw_mgr->iommu_hdl);
|
ctx_data->ctx_id_string, hw_mgr->iommu_hdl);
|
||||||
*fw_cmd_buf_iova_addr = 0;
|
*fw_cmd_buf_iova_addr = 0;
|
||||||
|
|
||||||
if (num_cmd_buf > 0)
|
|
||||||
num_cmd_buf--;
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
if ((len <= cmd_desc[i].offset) ||
|
if ((len <= cmd_desc[i].offset) ||
|
||||||
@@ -6630,10 +6623,6 @@ static int cam_icp_mgr_create_handle(struct cam_icp_hw_mgr *hw_mgr,
|
|||||||
int rc = 0;
|
int rc = 0;
|
||||||
uint32_t handle_type;
|
uint32_t handle_type;
|
||||||
|
|
||||||
task = cam_req_mgr_workq_get_task(hw_mgr->cmd_work);
|
|
||||||
if (!task)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
if (ctx_data->hw_dev_type == CAM_ICP_DEV_OFE) {
|
if (ctx_data->hw_dev_type == CAM_ICP_DEV_OFE) {
|
||||||
create_handle.pkt_type = HFI_CMD_OFE_CREATE_HANDLE;
|
create_handle.pkt_type = HFI_CMD_OFE_CREATE_HANDLE;
|
||||||
switch (dev_type) {
|
switch (dev_type) {
|
||||||
@@ -6646,6 +6635,9 @@ static int cam_icp_mgr_create_handle(struct cam_icp_hw_mgr *hw_mgr,
|
|||||||
case CAM_ICP_RES_TYPE_OFE_SEMI_RT:
|
case CAM_ICP_RES_TYPE_OFE_SEMI_RT:
|
||||||
handle_type = HFI_OFE_HANDLE_TYPE_OFE_SEMI_RT;
|
handle_type = HFI_OFE_HANDLE_TYPE_OFE_SEMI_RT;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
CAM_ERR(CAM_ICP, "Invalid OFE stream type: %u", dev_type);
|
||||||
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
create_handle.pkt_type = HFI_CMD_IPEBPS_CREATE_HANDLE;
|
create_handle.pkt_type = HFI_CMD_IPEBPS_CREATE_HANDLE;
|
||||||
@@ -6668,10 +6660,17 @@ static int cam_icp_mgr_create_handle(struct cam_icp_hw_mgr *hw_mgr,
|
|||||||
case CAM_ICP_RES_TYPE_BPS_SEMI_RT:
|
case CAM_ICP_RES_TYPE_BPS_SEMI_RT:
|
||||||
handle_type = HFI_IPEBPS_HANDLE_TYPE_BPS_SEMI_RT;
|
handle_type = HFI_IPEBPS_HANDLE_TYPE_BPS_SEMI_RT;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
CAM_ERR(CAM_ICP, "Invalid IPE/BPS stream type: %u", dev_type);
|
||||||
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
task = cam_req_mgr_workq_get_task(hw_mgr->cmd_work);
|
||||||
|
if (!task)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
create_handle.size = sizeof(struct hfi_cmd_create_handle);
|
create_handle.size = sizeof(struct hfi_cmd_create_handle);
|
||||||
create_handle.handle_type = dev_type;
|
create_handle.handle_type = handle_type;
|
||||||
create_handle.user_data1 = PTR_TO_U64(ctx_data);
|
create_handle.user_data1 = PTR_TO_U64(ctx_data);
|
||||||
reinit_completion(&ctx_data->wait_complete);
|
reinit_completion(&ctx_data->wait_complete);
|
||||||
task_data = (struct hfi_cmd_work_data *)task->payload;
|
task_data = (struct hfi_cmd_work_data *)task->payload;
|
||||||
|
Reference in New Issue
Block a user