Loading drivers/media/platform/msm/camera/cam_cdm/cam_cdm_virtual_core.c +9 −1 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include <linux/delay.h> Loading Loading @@ -111,6 +111,14 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw, if ((!rc) && (vaddr_ptr) && (len) && (len >= cdm_cmd->cmd[i].offset)) { if ((len - cdm_cmd->cmd[i].offset) <= cdm_cmd->cmd[i].len) { CAM_ERR(CAM_CDM, "Not enough buffer"); rc = -EINVAL; break; } CAM_DBG(CAM_CDM, "hdl=%x vaddr=%pK offset=%d cmdlen=%d:%zu", cdm_cmd->cmd[i].bl_addr.mem_handle, Loading drivers/media/platform/msm/camera/cam_core/cam_context.c +3 −1 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include <linux/slab.h> Loading Loading @@ -165,6 +165,7 @@ int cam_context_handle_crm_apply_req(struct cam_context *ctx, return -EINVAL; } mutex_lock(&ctx->ctx_mutex); if (ctx->state_machine[ctx->state].crm_ops.apply_req) { rc = ctx->state_machine[ctx->state].crm_ops.apply_req(ctx, apply); Loading @@ -173,6 +174,7 @@ int cam_context_handle_crm_apply_req(struct cam_context *ctx, ctx->dev_hdl, ctx->state); rc = -EPROTO; } mutex_unlock(&ctx->ctx_mutex); return rc; } Loading drivers/media/platform/msm/camera/cam_core/cam_context_utils.c +19 −2 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include <linux/debugfs.h> Loading Loading @@ -268,6 +268,7 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx, uintptr_t packet_addr; struct cam_packet *packet; size_t len = 0; size_t remain_len = 0; int32_t i = 0, j = 0; if (!ctx || !cmd) { Loading Loading @@ -313,11 +314,26 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx, goto free_req; } if ((len < sizeof(struct cam_packet)) || (cmd->offset >= (len - sizeof(struct cam_packet)))) { CAM_ERR(CAM_CTXT, "Not enough buf"); return -EINVAL; } remain_len = len; if ((len < sizeof(struct cam_packet)) || ((size_t)cmd->offset >= len - sizeof(struct cam_packet))) { CAM_ERR(CAM_CTXT, "invalid buff length: %zu or offset", len); rc = -EINVAL; goto free_cpu_buf; } remain_len -= (size_t)cmd->offset; packet = (struct cam_packet *) ((uint8_t *)packet_addr + (uint32_t)cmd->offset); if (packet->header.request_id <= ctx->last_flush_req) { CAM_DBG(CAM_CORE, CAM_ERR(CAM_CORE, "request %lld has been flushed, reject packet", packet->header.request_id); rc = -EINVAL; Loading @@ -330,6 +346,7 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx, /* preprocess the configuration */ memset(&cfg, 0, sizeof(cfg)); cfg.packet = packet; cfg.remain_len = remain_len; cfg.ctxt_to_hw_map = ctx->ctxt_to_hw_map; cfg.max_hw_update_entries = CAM_CTX_CFG_MAX; cfg.num_hw_update_entries = req->num_hw_update_entries; Loading drivers/media/platform/msm/camera/cam_core/cam_hw_mgr_intf.h +3 −1 Original line number Diff line number Diff line /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #ifndef _CAM_HW_MGR_INTF_H_ Loading Loading @@ -146,6 +146,7 @@ struct cam_hw_mgr_dump_pf_data { * struct cam_hw_prepare_update_args - Payload for prepare command * * @packet: CSL packet from user mode driver * @remain_len Remaining length of CPU buffer after config offset * @ctxt_to_hw_map: HW context from the acquire * @max_hw_update_entries: Maximum hardware update entries supported * @hw_update_entries: Actual hardware update configuration (returned) Loading @@ -162,6 +163,7 @@ struct cam_hw_mgr_dump_pf_data { */ struct cam_hw_prepare_update_args { struct cam_packet *packet; size_t remain_len; void *ctxt_to_hw_map; uint32_t max_hw_update_entries; struct cam_hw_update_entry *hw_update_entries; Loading drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c +27 −6 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include <linux/module.h> Loading @@ -23,7 +23,8 @@ static struct cam_fd_hw_mgr g_fd_hw_mgr; static int cam_fd_mgr_util_packet_validate(struct cam_packet *packet) static int cam_fd_mgr_util_packet_validate(struct cam_packet *packet, size_t remain_len) { struct cam_cmd_buf_desc *cmd_desc = NULL; int i, rc; Loading @@ -43,7 +44,7 @@ static int cam_fd_mgr_util_packet_validate(struct cam_packet *packet) packet->patch_offset, packet->num_patches, packet->kmd_cmd_buf_offset, packet->kmd_cmd_buf_index); if (cam_packet_util_validate_packet(packet)) { if (cam_packet_util_validate_packet(packet, remain_len)) { CAM_ERR(CAM_FD, "invalid packet:%d %d %d %d %d", packet->kmd_cmd_buf_index, packet->num_cmd_buf, packet->cmd_buf_offset, Loading Loading @@ -155,8 +156,10 @@ static int cam_fd_mgr_util_put_frame_req( mutex_lock(&g_fd_hw_mgr.frame_req_mutex); req_ptr = *frame_req; if (req_ptr) if (req_ptr) { list_del_init(&req_ptr->list); list_add_tail(&req_ptr->list, src_list); } *frame_req = NULL; mutex_unlock(&g_fd_hw_mgr.frame_req_mutex); Loading Loading @@ -602,7 +605,14 @@ static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl, rc); goto rel_cpu_buf; } if (io_cfg[i].offsets[plane] >= size) { CAM_ERR(CAM_FD, "Invalid cpu buf %d %d %d", io_cfg[i].direction, io_cfg[i].resource_type, plane); rc = -EINVAL; goto rel_cpu_buf; } cpu_addr[plane] += io_cfg[i].offsets[plane]; } Loading Loading @@ -1458,6 +1468,16 @@ static int cam_fd_mgr_hw_flush_ctx(void *hw_mgr_priv, for (i = 0; i < flush_args->num_req_pending; i++) { flush_req = (struct cam_fd_mgr_frame_request *) flush_args->flush_req_pending[i]; CAM_DBG(CAM_FD, "flush pending req %llu", flush_req->request_id); cam_fd_mgr_util_put_frame_req(&hw_mgr->frame_free_list, &flush_req); } for (i = 0; i < flush_args->num_req_active; i++) { flush_req = (struct cam_fd_mgr_frame_request *) flush_args->flush_req_active[i]; CAM_DBG(CAM_FD, "flush active req %llu", flush_req->request_id); cam_fd_mgr_util_put_frame_req(&hw_mgr->frame_free_list, &flush_req); } Loading Loading @@ -1573,7 +1593,8 @@ static int cam_fd_mgr_hw_prepare_update(void *hw_mgr_priv, goto error; } rc = cam_fd_mgr_util_packet_validate(prepare->packet); rc = cam_fd_mgr_util_packet_validate(prepare->packet, prepare->remain_len); if (rc) { CAM_ERR(CAM_FD, "Error in packet validation %d", rc); goto error; Loading Loading
drivers/media/platform/msm/camera/cam_cdm/cam_cdm_virtual_core.c +9 −1 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include <linux/delay.h> Loading Loading @@ -111,6 +111,14 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw, if ((!rc) && (vaddr_ptr) && (len) && (len >= cdm_cmd->cmd[i].offset)) { if ((len - cdm_cmd->cmd[i].offset) <= cdm_cmd->cmd[i].len) { CAM_ERR(CAM_CDM, "Not enough buffer"); rc = -EINVAL; break; } CAM_DBG(CAM_CDM, "hdl=%x vaddr=%pK offset=%d cmdlen=%d:%zu", cdm_cmd->cmd[i].bl_addr.mem_handle, Loading
drivers/media/platform/msm/camera/cam_core/cam_context.c +3 −1 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include <linux/slab.h> Loading Loading @@ -165,6 +165,7 @@ int cam_context_handle_crm_apply_req(struct cam_context *ctx, return -EINVAL; } mutex_lock(&ctx->ctx_mutex); if (ctx->state_machine[ctx->state].crm_ops.apply_req) { rc = ctx->state_machine[ctx->state].crm_ops.apply_req(ctx, apply); Loading @@ -173,6 +174,7 @@ int cam_context_handle_crm_apply_req(struct cam_context *ctx, ctx->dev_hdl, ctx->state); rc = -EPROTO; } mutex_unlock(&ctx->ctx_mutex); return rc; } Loading
drivers/media/platform/msm/camera/cam_core/cam_context_utils.c +19 −2 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include <linux/debugfs.h> Loading Loading @@ -268,6 +268,7 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx, uintptr_t packet_addr; struct cam_packet *packet; size_t len = 0; size_t remain_len = 0; int32_t i = 0, j = 0; if (!ctx || !cmd) { Loading Loading @@ -313,11 +314,26 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx, goto free_req; } if ((len < sizeof(struct cam_packet)) || (cmd->offset >= (len - sizeof(struct cam_packet)))) { CAM_ERR(CAM_CTXT, "Not enough buf"); return -EINVAL; } remain_len = len; if ((len < sizeof(struct cam_packet)) || ((size_t)cmd->offset >= len - sizeof(struct cam_packet))) { CAM_ERR(CAM_CTXT, "invalid buff length: %zu or offset", len); rc = -EINVAL; goto free_cpu_buf; } remain_len -= (size_t)cmd->offset; packet = (struct cam_packet *) ((uint8_t *)packet_addr + (uint32_t)cmd->offset); if (packet->header.request_id <= ctx->last_flush_req) { CAM_DBG(CAM_CORE, CAM_ERR(CAM_CORE, "request %lld has been flushed, reject packet", packet->header.request_id); rc = -EINVAL; Loading @@ -330,6 +346,7 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx, /* preprocess the configuration */ memset(&cfg, 0, sizeof(cfg)); cfg.packet = packet; cfg.remain_len = remain_len; cfg.ctxt_to_hw_map = ctx->ctxt_to_hw_map; cfg.max_hw_update_entries = CAM_CTX_CFG_MAX; cfg.num_hw_update_entries = req->num_hw_update_entries; Loading
drivers/media/platform/msm/camera/cam_core/cam_hw_mgr_intf.h +3 −1 Original line number Diff line number Diff line /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #ifndef _CAM_HW_MGR_INTF_H_ Loading Loading @@ -146,6 +146,7 @@ struct cam_hw_mgr_dump_pf_data { * struct cam_hw_prepare_update_args - Payload for prepare command * * @packet: CSL packet from user mode driver * @remain_len Remaining length of CPU buffer after config offset * @ctxt_to_hw_map: HW context from the acquire * @max_hw_update_entries: Maximum hardware update entries supported * @hw_update_entries: Actual hardware update configuration (returned) Loading @@ -162,6 +163,7 @@ struct cam_hw_mgr_dump_pf_data { */ struct cam_hw_prepare_update_args { struct cam_packet *packet; size_t remain_len; void *ctxt_to_hw_map; uint32_t max_hw_update_entries; struct cam_hw_update_entry *hw_update_entries; Loading
drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c +27 −6 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include <linux/module.h> Loading @@ -23,7 +23,8 @@ static struct cam_fd_hw_mgr g_fd_hw_mgr; static int cam_fd_mgr_util_packet_validate(struct cam_packet *packet) static int cam_fd_mgr_util_packet_validate(struct cam_packet *packet, size_t remain_len) { struct cam_cmd_buf_desc *cmd_desc = NULL; int i, rc; Loading @@ -43,7 +44,7 @@ static int cam_fd_mgr_util_packet_validate(struct cam_packet *packet) packet->patch_offset, packet->num_patches, packet->kmd_cmd_buf_offset, packet->kmd_cmd_buf_index); if (cam_packet_util_validate_packet(packet)) { if (cam_packet_util_validate_packet(packet, remain_len)) { CAM_ERR(CAM_FD, "invalid packet:%d %d %d %d %d", packet->kmd_cmd_buf_index, packet->num_cmd_buf, packet->cmd_buf_offset, Loading Loading @@ -155,8 +156,10 @@ static int cam_fd_mgr_util_put_frame_req( mutex_lock(&g_fd_hw_mgr.frame_req_mutex); req_ptr = *frame_req; if (req_ptr) if (req_ptr) { list_del_init(&req_ptr->list); list_add_tail(&req_ptr->list, src_list); } *frame_req = NULL; mutex_unlock(&g_fd_hw_mgr.frame_req_mutex); Loading Loading @@ -602,7 +605,14 @@ static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl, rc); goto rel_cpu_buf; } if (io_cfg[i].offsets[plane] >= size) { CAM_ERR(CAM_FD, "Invalid cpu buf %d %d %d", io_cfg[i].direction, io_cfg[i].resource_type, plane); rc = -EINVAL; goto rel_cpu_buf; } cpu_addr[plane] += io_cfg[i].offsets[plane]; } Loading Loading @@ -1458,6 +1468,16 @@ static int cam_fd_mgr_hw_flush_ctx(void *hw_mgr_priv, for (i = 0; i < flush_args->num_req_pending; i++) { flush_req = (struct cam_fd_mgr_frame_request *) flush_args->flush_req_pending[i]; CAM_DBG(CAM_FD, "flush pending req %llu", flush_req->request_id); cam_fd_mgr_util_put_frame_req(&hw_mgr->frame_free_list, &flush_req); } for (i = 0; i < flush_args->num_req_active; i++) { flush_req = (struct cam_fd_mgr_frame_request *) flush_args->flush_req_active[i]; CAM_DBG(CAM_FD, "flush active req %llu", flush_req->request_id); cam_fd_mgr_util_put_frame_req(&hw_mgr->frame_free_list, &flush_req); } Loading Loading @@ -1573,7 +1593,8 @@ static int cam_fd_mgr_hw_prepare_update(void *hw_mgr_priv, goto error; } rc = cam_fd_mgr_util_packet_validate(prepare->packet); rc = cam_fd_mgr_util_packet_validate(prepare->packet, prepare->remain_len); if (rc) { CAM_ERR(CAM_FD, "Error in packet validation %d", rc); goto error; Loading