From c565be83b1edc6a1d3d7aab91fdd6b774efdc338 Mon Sep 17 00:00:00 2001 From: Pranav Sanwal Date: Thu, 21 Sep 2023 03:20:51 +0530 Subject: [PATCH] Camera: Bring over TFE specific changes Following gerrits combined: msm: camera: tfe: update debug data for overflow msm: camera: isp: Handling IRQ delay from CDM in tfe msm: camera: isp: Handling excessive logging in cdm callback msm: camera: tfe: Fix compilation issue msm: camera: uapi: Add new HW ports definition for TFE msm: camera: tfe: Add LDAR dump utility in TFE. CRs-Fixed: 3623803 Change-Id: I31e7b8d7cff654fd292ce431b790e0e287d6845e Signed-off-by: Pranav Sanwal --- drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c | 77 +++++++++++++++---- drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.h | 13 ++++ .../isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_core.c | 5 +- include/uapi/camera/media/cam_isp_tfe.h | 6 +- 4 files changed, 82 insertions(+), 19 deletions(-) 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 8cc5a18229..0941ae8ade 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 @@ -1716,27 +1716,32 @@ void cam_tfe_cam_cdm_callback(uint32_t handle, void *userdata, return; } + ctx = (struct cam_tfe_hw_mgr_ctx *)userdata; + hw_update_data = ctx->cdm_userdata.hw_update_data; + if (status == CAM_CDM_CB_STATUS_BL_SUCCESS) { - hw_update_data = - (struct cam_isp_prepare_hw_update_data *)userdata; - ctx = - (struct cam_tfe_hw_mgr_ctx *)hw_update_data->isp_mgr_ctx; complete_all(&ctx->config_done_complete); atomic_set(&ctx->cdm_done, 1); ctx->last_cdm_done_req = *(uint64_t *)cookie; - if (g_tfe_hw_mgr.debug_cfg.per_req_reg_dump) - cam_tfe_mgr_handle_reg_dump(ctx, - hw_update_data->reg_dump_buf_desc, - hw_update_data->num_reg_dump_buf, - CAM_ISP_TFE_PACKET_META_REG_DUMP_PER_REQUEST, - NULL, false); + if (g_tfe_hw_mgr.debug_cfg.per_req_reg_dump) { + if (ctx->cdm_userdata.request_id == *(uint64_t *)cookie) { + cam_tfe_mgr_handle_reg_dump(ctx, + hw_update_data->reg_dump_buf_desc, + hw_update_data->num_reg_dump_buf, + CAM_ISP_TFE_PACKET_META_REG_DUMP_PER_REQUEST, + NULL, false); + } else { + CAM_INFO(CAM_ISP, "CDM delay, Skip dump req: %llu, cdm_req: %llu", + *(uint64_t *)cookie, ctx->cdm_userdata.request_id); + } + } CAM_DBG(CAM_ISP, - "Called by CDM hdl=%x, udata=%pK, status=%d, cookie=%llu ctx_index=%d", - handle, userdata, status, *(uint64_t *)cookie, ctx->ctx_index); + "CDM hdl=%x, udata=%pK, status=%d, cookie=%llu ctx_index=%d cdm_req=%llu", + handle, userdata, status, cookie, ctx->ctx_index, + ctx->cdm_userdata.request_id); } else if (status == CAM_CDM_CB_STATUS_PAGEFAULT || status == CAM_CDM_CB_STATUS_INVALID_BL_CMD || status == CAM_CDM_CB_STATUS_HW_ERROR) { - ctx = userdata; CAM_INFO(CAM_ISP, "req_id =%d ctx_id =%d Bl_cmd_count =%d status=%d", ctx->applied_req_id, ctx->ctx_index, @@ -1772,8 +1777,8 @@ void cam_tfe_cam_cdm_callback(uint32_t handle, void *userdata, } else { CAM_WARN(CAM_ISP, - "Called by CDM hdl=%x, udata=%pK, status=%d, cookie=%llu", - handle, userdata, status, *(uint64_t *)cookie); + "CDM hdl=%x, udata=%pK, status=%d, cookie=%llu cdm_req=%llu", + handle, userdata, status, cookie, ctx->cdm_userdata.request_id); } } @@ -2749,6 +2754,8 @@ static int cam_tfe_mgr_config_hw(void *hw_mgr_priv, hw_update_data = (struct cam_isp_prepare_hw_update_data *) cfg->priv; hw_update_data->isp_mgr_ctx = ctx; + ctx->cdm_userdata.request_id = cfg->request_id; + ctx->cdm_userdata.hw_update_data = hw_update_data; if (cfg->reapply_type && cfg->cdm_reset_before_apply) { if (ctx->last_cdm_done_req < cfg->request_id) { @@ -2811,7 +2818,7 @@ static int cam_tfe_mgr_config_hw(void *hw_mgr_priv, cdm_cmd->cmd_arrary_count = cfg->num_hw_update_entries; cdm_cmd->type = CAM_CDM_BL_CMD_TYPE_MEM_HANDLE; cdm_cmd->flag = true; - cdm_cmd->userdata = hw_update_data; + cdm_cmd->userdata = ctx; cdm_cmd->cookie = cfg->request_id; cdm_cmd->gen_irq_arb = false; cdm_cmd->genirq_buff = &hw_update_data->kmd_cmd_buff_info; @@ -5086,6 +5093,38 @@ outportlog: } +static void *cam_tfe_mgr_user_dump_stream_info( + void *dump_struct, uint8_t *addr_ptr) +{ + struct cam_tfe_hw_mgr_ctx *ctx = NULL; + struct cam_isp_hw_mgr_res *hw_mgr_res = NULL; + struct cam_isp_resource_node *hw_res = NULL; + int32_t *addr; + int i; + int hw_idx[CAM_ISP_HW_SPLIT_MAX] = { -1, -1 }; + + ctx = (struct cam_tfe_hw_mgr_ctx *)dump_struct; + + if (!list_empty(&ctx->res_list_tfe_in)) { + hw_mgr_res = list_first_entry(&ctx->res_list_tfe_in, + struct cam_isp_hw_mgr_res, list); + + for (i = 0; i < CAM_ISP_HW_SPLIT_MAX; i++) { + hw_res = hw_mgr_res->hw_res[i]; + if (hw_res && hw_res->hw_intf) + hw_idx[i] = hw_res->hw_intf->hw_idx; + } + } + + addr = (int32_t *)addr_ptr; + + *addr++ = ctx->is_dual; + *addr++ = hw_idx[CAM_ISP_HW_SPLIT_LEFT]; + *addr++ = hw_idx[CAM_ISP_HW_SPLIT_RIGHT]; + + return addr; +} + static int cam_tfe_mgr_cmd(void *hw_mgr_priv, void *cmd_args) { int rc = 0; @@ -5165,6 +5204,12 @@ static int cam_tfe_mgr_cmd(void *hw_mgr_priv, void *cmd_args) case CAM_ISP_HW_MGR_CMD_UPDATE_CLOCK: rc = cam_tfe_hw_mgr_csiphy_clk_sync(ctx, isp_hw_cmd_args->cmd_data); break; + case CAM_ISP_HW_MGR_DUMP_STREAM_INFO: + rc = cam_common_user_dump_helper( + (void *)(isp_hw_cmd_args->cmd_data), + cam_tfe_mgr_user_dump_stream_info, ctx, + sizeof(int32_t), "ISP_STREAM_INFO_FROM_TFE_HW_MGR:"); + break; default: CAM_ERR(CAM_ISP, "Invalid HW mgr command:0x%x, ISP HW mgr cmd:0x%x", hw_cmd_args->cmd_type, isp_hw_cmd_args->cmd_type); diff --git a/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.h b/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.h index bbf6262d3e..c7649b5f2d 100644 --- a/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.h +++ b/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.h @@ -72,6 +72,17 @@ struct cam_tfe_comp_record_query { void *reserved; }; +/** + * struct cam_tfe_cdm_user_data - TFE HW user data with CDM + * + * @prepare: hw_update_data + * @request_id: Request id + */ +struct cam_tfe_cdm_user_data { + struct cam_isp_prepare_hw_update_data *hw_update_data; + uint64_t request_id; +}; + /** * struct cam_tfe_hw_mgr_ctx - TFE HW manager Context object * @@ -114,6 +125,7 @@ struct cam_tfe_comp_record_query { * @packet CSL packet from user mode driver * @bw_config_version BW Config version * @tfe_bus_comp_grp pointer to tfe comp group info + * @cdm_userdata CDM user data */ struct cam_tfe_hw_mgr_ctx { struct list_head list; @@ -157,6 +169,7 @@ struct cam_tfe_hw_mgr_ctx { struct cam_packet *packet; uint32_t bw_config_version; struct cam_tfe_hw_comp_record *tfe_bus_comp_grp; + struct cam_tfe_cdm_user_data cdm_userdata; }; /** diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_core.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_core.c index 4f9833eaa4..19cb044783 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_core.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_core.c @@ -349,7 +349,7 @@ static void cam_tfe_log_error_irq_status( for (i = 0; i < top_priv->common_data.common_reg->num_debug_reg; i++) { val_0 = cam_io_r(mem_base + top_priv->common_data.common_reg->debug_reg[i]); - CAM_INFO(CAM_ISP, "Top debug [i]:0x%x", i, val_0); + CAM_INFO(CAM_ISP, "Top debug [%d]:0x%x", i, val_0); } cam_cpas_dump_camnoc_buff_fill_info(soc_private->cpas_handle); @@ -445,7 +445,8 @@ static void cam_tfe_log_error_irq_status( "TFE clock rate:%d TFE total bw applied:%lld", top_priv->hw_clk_rate, top_priv->total_bw_applied); - cam_cpas_log_votes(); + + cam_cpas_log_votes(false); } static int cam_tfe_error_irq_bottom_half( diff --git a/include/uapi/camera/media/cam_isp_tfe.h b/include/uapi/camera/media/cam_isp_tfe.h index 755bd13525..4a307d6581 100644 --- a/include/uapi/camera/media/cam_isp_tfe.h +++ b/include/uapi/camera/media/cam_isp_tfe.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ /* * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef __UAPI_CAM_ISP_TFE_H__ @@ -24,7 +25,10 @@ #define CAM_ISP_TFE_OUT_RES_DS4 (CAM_ISP_TFE_OUT_RES_BASE + 12) #define CAM_ISP_TFE_OUT_RES_DS16 (CAM_ISP_TFE_OUT_RES_BASE + 13) #define CAM_ISP_TFE_OUT_RES_AI (CAM_ISP_TFE_OUT_RES_BASE + 14) -#define CAM_ISP_TFE_OUT_RES_MAX (CAM_ISP_TFE_OUT_RES_BASE + 15) +#define CAM_ISP_TFE_OUT_RES_PD_LCR_STATS (CAM_ISP_TFE_OUT_RES_BASE + 15) +#define CAM_ISP_TFE_OUT_RES_PD_PREPROCESSED (CAM_ISP_TFE_OUT_RES_BASE + 16) +#define CAM_ISP_TFE_OUT_RES_PD_PARSED (CAM_ISP_TFE_OUT_RES_BASE + 17) +#define CAM_ISP_TFE_OUT_RES_MAX (CAM_ISP_TFE_OUT_RES_BASE + 18) /* TFE input port resource type */