Loading drivers/cam_cdm/cam_cdm_virtual_core.c +16 −4 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include <linux/delay.h> Loading Loading @@ -115,7 +116,7 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw, cdm_cmd->cmd[i].len) { CAM_ERR(CAM_CDM, "Not enough buffer"); rc = -EINVAL; break; goto end; } CAM_DBG(CAM_CDM, "hdl=%x vaddr=%pK offset=%d cmdlen=%d:%zu", Loading @@ -133,7 +134,7 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw, "write failed for cnt=%d:%d len %u", i, req->data->cmd_arrary_count, cdm_cmd->cmd[i].len); break; goto end; } } else { CAM_ERR(CAM_CDM, Loading @@ -144,7 +145,7 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw, "Sanity check failed for cmd_count=%d cnt=%d", i, req->data->cmd_arrary_count); rc = -EINVAL; break; goto end; } if (!rc) { struct cam_cdm_work_payload *payload; Loading @@ -161,7 +162,7 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw, GFP_KERNEL); if (!node) { rc = -ENOMEM; break; goto end; } node->request_type = CAM_HW_CDM_BL_CB_CLIENT; node->client_hdl = req->handle; Loading Loading @@ -193,9 +194,20 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw, if (!rc && (core->bl_tag == 63)) core->bl_tag = 0; } if (req->data->type == CAM_CDM_BL_CMD_TYPE_MEM_HANDLE) cam_mem_put_cpu_buf(cdm_cmd->cmd[i].bl_addr.mem_handle); } mutex_unlock(&client->lock); return rc; end: if (req->data->type == CAM_CDM_BL_CMD_TYPE_MEM_HANDLE) cam_mem_put_cpu_buf(cdm_cmd->cmd[i].bl_addr.mem_handle); mutex_unlock(&client->lock); return rc; } int cam_virtual_cdm_probe(struct platform_device *pdev) Loading drivers/cam_core/cam_context_utils.c +6 −1 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include <linux/debugfs.h> Loading Loading @@ -321,6 +322,7 @@ int32_t cam_context_config_dev_to_hw( rc = -EFAULT; } cam_mem_put_cpu_buf((int32_t) cmd->packet_handle); return rc; } Loading Loading @@ -1107,6 +1109,7 @@ static int cam_context_dump_context(struct cam_context *ctx, if (dump_args->offset >= buf_len) { CAM_WARN(CAM_CTXT, "dump buffer overshoot offset %zu len %zu", dump_args->offset, buf_len); cam_mem_put_cpu_buf(dump_args->buf_handle); return -ENOSPC; } Loading @@ -1118,6 +1121,7 @@ static int cam_context_dump_context(struct cam_context *ctx, if (remain_len < min_len) { CAM_WARN(CAM_CTXT, "dump buffer exhaust remain %zu min %u", remain_len, min_len); cam_mem_put_cpu_buf(dump_args->buf_handle); return -ENOSPC; } dst = (uint8_t *)cpu_addr + dump_args->offset; Loading @@ -1142,7 +1146,8 @@ static int cam_context_dump_context(struct cam_context *ctx, hdr->size = hdr->word_size * (addr - start); dump_args->offset += hdr->size + sizeof(struct cam_context_dump_header); return rc; cam_mem_put_cpu_buf(dump_args->buf_handle); return 0; } int32_t cam_context_dump_dev_to_hw(struct cam_context *ctx, Loading drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw_mgr.c +2 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include <linux/slab.h> Loading Loading @@ -1129,6 +1130,7 @@ static int cam_custom_mgr_prepare_hw_update(void *hw_mgr_priv, } cam_custom_add_io_buffers(hw_mgr->img_iommu_hdl, prepare); cam_mem_put_cpu_buf(cmd_desc->mem_handle); return 0; } Loading drivers/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c +41 −3 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, 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 <linux/module.h> Loading Loading @@ -543,6 +543,33 @@ static int cam_fd_mgr_util_get_buf_map_requirement(uint32_t direction, return 0; } static int cam_fd_mgr_put_cpu_buf(struct cam_hw_prepare_update_args *prepare) { int i, rc; uint32_t plane; bool need_io_map, need_cpu_map; struct cam_buf_io_cfg *io_cfg; io_cfg = (struct cam_buf_io_cfg *) ((uint8_t *) &prepare->packet->payload + prepare->packet->io_configs_offset); if (!io_cfg) return -EINVAL; for (i = 0; i < prepare->packet->num_io_configs; i++) { rc = cam_fd_mgr_util_get_buf_map_requirement( io_cfg[i].direction, io_cfg[i].resource_type, &need_io_map, &need_cpu_map); if (rc || !need_cpu_map) continue; for (plane = 0; plane < CAM_PACKET_MAX_PLANES; plane++) cam_mem_put_cpu_buf(io_cfg[i].mem_handle[plane]); } return 0; } static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl, struct cam_hw_prepare_update_args *prepare, struct cam_fd_hw_io_buffer *input_buf, Loading Loading @@ -639,6 +666,8 @@ static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl, "Invalid cpu buf %d %d %d", io_cfg[i].direction, io_cfg[i].resource_type, plane); cam_mem_put_cpu_buf( io_cfg[i].mem_handle[plane]); rc = -EINVAL; return rc; } Loading Loading @@ -1618,6 +1647,7 @@ static int cam_fd_mgr_hw_dump( if (fd_dump_args.buf_len <= dump_args->offset) { CAM_WARN(CAM_FD, "dump offset overshoot len %zu offset %zu", fd_dump_args.buf_len, dump_args->offset); cam_mem_put_cpu_buf(dump_args->buf_handle); return -ENOSPC; } remain_len = fd_dump_args.buf_len - dump_args->offset; Loading @@ -1627,6 +1657,7 @@ static int cam_fd_mgr_hw_dump( if (remain_len < min_len) { CAM_WARN(CAM_FD, "dump buffer exhaust remain %zu min %u", remain_len, min_len); cam_mem_put_cpu_buf(dump_args->buf_handle); return -ENOSPC; } Loading Loading @@ -1658,12 +1689,14 @@ static int cam_fd_mgr_hw_dump( if (rc) { CAM_ERR(CAM_FD, "Hw Dump cmd fails req %lld rc %d", frame_req->request_id, rc); cam_mem_put_cpu_buf(dump_args->buf_handle); return rc; } } CAM_DBG(CAM_FD, "Offset before %zu after %zu", dump_args->offset, fd_dump_args.offset); dump_args->offset = fd_dump_args.offset; cam_mem_put_cpu_buf(dump_args->buf_handle); return rc; } Loading Loading @@ -1797,7 +1830,7 @@ static int cam_fd_mgr_hw_prepare_update(void *hw_mgr_priv, &prestart_args, &kmd_buf); if (rc) { CAM_ERR(CAM_FD, "Error in hw update entries %d", rc); goto error; goto put_cpu_buf; } /* get a free frame req from free list */ Loading @@ -1806,7 +1839,8 @@ static int cam_fd_mgr_hw_prepare_update(void *hw_mgr_priv, if (rc || !frame_req) { CAM_ERR(CAM_FD, "Get frame_req failed, rc=%d, hw_ctx=%pK", rc, hw_ctx); return -ENOMEM; rc = -ENOMEM; goto put_cpu_buf; } /* Setup frame request info and queue to pending list */ Loading @@ -1821,9 +1855,13 @@ static int cam_fd_mgr_hw_prepare_update(void *hw_mgr_priv, */ prepare->priv = frame_req; cam_fd_mgr_put_cpu_buf(prepare); CAM_DBG(CAM_FD, "FramePrepare : Frame[%lld]", frame_req->request_id); return 0; put_cpu_buf: cam_fd_mgr_put_cpu_buf(prepare); error: return rc; } Loading drivers/cam_icp/cam_icp_context.c +4 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include <linux/debugfs.h> Loading Loading @@ -156,6 +157,7 @@ static int __cam_icp_config_dev_in_ready(struct cam_context *ctx, CAM_ERR(CAM_CTXT, "Invalid offset, len: %zu cmd offset: %llu sizeof packet: %zu", len, cmd->offset, sizeof(struct cam_packet)); cam_mem_put_cpu_buf((int32_t) cmd->packet_handle); return -EINVAL; } Loading @@ -167,6 +169,7 @@ static int __cam_icp_config_dev_in_ready(struct cam_context *ctx, if (rc) { CAM_ERR(CAM_CTXT, "Invalid packet params, remain length: %zu", remain_len); cam_mem_put_cpu_buf((int32_t) cmd->packet_handle); return rc; } Loading @@ -181,6 +184,7 @@ static int __cam_icp_config_dev_in_ready(struct cam_context *ctx, if (rc) CAM_ERR(CAM_ICP, "Failed to prepare device"); cam_mem_put_cpu_buf((int32_t) cmd->packet_handle); return rc; } Loading Loading
drivers/cam_cdm/cam_cdm_virtual_core.c +16 −4 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include <linux/delay.h> Loading Loading @@ -115,7 +116,7 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw, cdm_cmd->cmd[i].len) { CAM_ERR(CAM_CDM, "Not enough buffer"); rc = -EINVAL; break; goto end; } CAM_DBG(CAM_CDM, "hdl=%x vaddr=%pK offset=%d cmdlen=%d:%zu", Loading @@ -133,7 +134,7 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw, "write failed for cnt=%d:%d len %u", i, req->data->cmd_arrary_count, cdm_cmd->cmd[i].len); break; goto end; } } else { CAM_ERR(CAM_CDM, Loading @@ -144,7 +145,7 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw, "Sanity check failed for cmd_count=%d cnt=%d", i, req->data->cmd_arrary_count); rc = -EINVAL; break; goto end; } if (!rc) { struct cam_cdm_work_payload *payload; Loading @@ -161,7 +162,7 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw, GFP_KERNEL); if (!node) { rc = -ENOMEM; break; goto end; } node->request_type = CAM_HW_CDM_BL_CB_CLIENT; node->client_hdl = req->handle; Loading Loading @@ -193,9 +194,20 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw, if (!rc && (core->bl_tag == 63)) core->bl_tag = 0; } if (req->data->type == CAM_CDM_BL_CMD_TYPE_MEM_HANDLE) cam_mem_put_cpu_buf(cdm_cmd->cmd[i].bl_addr.mem_handle); } mutex_unlock(&client->lock); return rc; end: if (req->data->type == CAM_CDM_BL_CMD_TYPE_MEM_HANDLE) cam_mem_put_cpu_buf(cdm_cmd->cmd[i].bl_addr.mem_handle); mutex_unlock(&client->lock); return rc; } int cam_virtual_cdm_probe(struct platform_device *pdev) Loading
drivers/cam_core/cam_context_utils.c +6 −1 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include <linux/debugfs.h> Loading Loading @@ -321,6 +322,7 @@ int32_t cam_context_config_dev_to_hw( rc = -EFAULT; } cam_mem_put_cpu_buf((int32_t) cmd->packet_handle); return rc; } Loading Loading @@ -1107,6 +1109,7 @@ static int cam_context_dump_context(struct cam_context *ctx, if (dump_args->offset >= buf_len) { CAM_WARN(CAM_CTXT, "dump buffer overshoot offset %zu len %zu", dump_args->offset, buf_len); cam_mem_put_cpu_buf(dump_args->buf_handle); return -ENOSPC; } Loading @@ -1118,6 +1121,7 @@ static int cam_context_dump_context(struct cam_context *ctx, if (remain_len < min_len) { CAM_WARN(CAM_CTXT, "dump buffer exhaust remain %zu min %u", remain_len, min_len); cam_mem_put_cpu_buf(dump_args->buf_handle); return -ENOSPC; } dst = (uint8_t *)cpu_addr + dump_args->offset; Loading @@ -1142,7 +1146,8 @@ static int cam_context_dump_context(struct cam_context *ctx, hdr->size = hdr->word_size * (addr - start); dump_args->offset += hdr->size + sizeof(struct cam_context_dump_header); return rc; cam_mem_put_cpu_buf(dump_args->buf_handle); return 0; } int32_t cam_context_dump_dev_to_hw(struct cam_context *ctx, Loading
drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw_mgr.c +2 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include <linux/slab.h> Loading Loading @@ -1129,6 +1130,7 @@ static int cam_custom_mgr_prepare_hw_update(void *hw_mgr_priv, } cam_custom_add_io_buffers(hw_mgr->img_iommu_hdl, prepare); cam_mem_put_cpu_buf(cmd_desc->mem_handle); return 0; } Loading
drivers/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c +41 −3 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, 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 <linux/module.h> Loading Loading @@ -543,6 +543,33 @@ static int cam_fd_mgr_util_get_buf_map_requirement(uint32_t direction, return 0; } static int cam_fd_mgr_put_cpu_buf(struct cam_hw_prepare_update_args *prepare) { int i, rc; uint32_t plane; bool need_io_map, need_cpu_map; struct cam_buf_io_cfg *io_cfg; io_cfg = (struct cam_buf_io_cfg *) ((uint8_t *) &prepare->packet->payload + prepare->packet->io_configs_offset); if (!io_cfg) return -EINVAL; for (i = 0; i < prepare->packet->num_io_configs; i++) { rc = cam_fd_mgr_util_get_buf_map_requirement( io_cfg[i].direction, io_cfg[i].resource_type, &need_io_map, &need_cpu_map); if (rc || !need_cpu_map) continue; for (plane = 0; plane < CAM_PACKET_MAX_PLANES; plane++) cam_mem_put_cpu_buf(io_cfg[i].mem_handle[plane]); } return 0; } static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl, struct cam_hw_prepare_update_args *prepare, struct cam_fd_hw_io_buffer *input_buf, Loading Loading @@ -639,6 +666,8 @@ static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl, "Invalid cpu buf %d %d %d", io_cfg[i].direction, io_cfg[i].resource_type, plane); cam_mem_put_cpu_buf( io_cfg[i].mem_handle[plane]); rc = -EINVAL; return rc; } Loading Loading @@ -1618,6 +1647,7 @@ static int cam_fd_mgr_hw_dump( if (fd_dump_args.buf_len <= dump_args->offset) { CAM_WARN(CAM_FD, "dump offset overshoot len %zu offset %zu", fd_dump_args.buf_len, dump_args->offset); cam_mem_put_cpu_buf(dump_args->buf_handle); return -ENOSPC; } remain_len = fd_dump_args.buf_len - dump_args->offset; Loading @@ -1627,6 +1657,7 @@ static int cam_fd_mgr_hw_dump( if (remain_len < min_len) { CAM_WARN(CAM_FD, "dump buffer exhaust remain %zu min %u", remain_len, min_len); cam_mem_put_cpu_buf(dump_args->buf_handle); return -ENOSPC; } Loading Loading @@ -1658,12 +1689,14 @@ static int cam_fd_mgr_hw_dump( if (rc) { CAM_ERR(CAM_FD, "Hw Dump cmd fails req %lld rc %d", frame_req->request_id, rc); cam_mem_put_cpu_buf(dump_args->buf_handle); return rc; } } CAM_DBG(CAM_FD, "Offset before %zu after %zu", dump_args->offset, fd_dump_args.offset); dump_args->offset = fd_dump_args.offset; cam_mem_put_cpu_buf(dump_args->buf_handle); return rc; } Loading Loading @@ -1797,7 +1830,7 @@ static int cam_fd_mgr_hw_prepare_update(void *hw_mgr_priv, &prestart_args, &kmd_buf); if (rc) { CAM_ERR(CAM_FD, "Error in hw update entries %d", rc); goto error; goto put_cpu_buf; } /* get a free frame req from free list */ Loading @@ -1806,7 +1839,8 @@ static int cam_fd_mgr_hw_prepare_update(void *hw_mgr_priv, if (rc || !frame_req) { CAM_ERR(CAM_FD, "Get frame_req failed, rc=%d, hw_ctx=%pK", rc, hw_ctx); return -ENOMEM; rc = -ENOMEM; goto put_cpu_buf; } /* Setup frame request info and queue to pending list */ Loading @@ -1821,9 +1855,13 @@ static int cam_fd_mgr_hw_prepare_update(void *hw_mgr_priv, */ prepare->priv = frame_req; cam_fd_mgr_put_cpu_buf(prepare); CAM_DBG(CAM_FD, "FramePrepare : Frame[%lld]", frame_req->request_id); return 0; put_cpu_buf: cam_fd_mgr_put_cpu_buf(prepare); error: return rc; } Loading
drivers/cam_icp/cam_icp_context.c +4 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include <linux/debugfs.h> Loading Loading @@ -156,6 +157,7 @@ static int __cam_icp_config_dev_in_ready(struct cam_context *ctx, CAM_ERR(CAM_CTXT, "Invalid offset, len: %zu cmd offset: %llu sizeof packet: %zu", len, cmd->offset, sizeof(struct cam_packet)); cam_mem_put_cpu_buf((int32_t) cmd->packet_handle); return -EINVAL; } Loading @@ -167,6 +169,7 @@ static int __cam_icp_config_dev_in_ready(struct cam_context *ctx, if (rc) { CAM_ERR(CAM_CTXT, "Invalid packet params, remain length: %zu", remain_len); cam_mem_put_cpu_buf((int32_t) cmd->packet_handle); return rc; } Loading @@ -181,6 +184,7 @@ static int __cam_icp_config_dev_in_ready(struct cam_context *ctx, if (rc) CAM_ERR(CAM_ICP, "Failed to prepare device"); cam_mem_put_cpu_buf((int32_t) cmd->packet_handle); return rc; } Loading