Browse Source

msm: camera: isp: Improve debug infrastructure

Address enabling CSID IRQs on SOF freeze. Enable the input
IRQ events when state machine encounters congestion as well.

CRs-Fixed: 3309151
Change-Id: Ib7611167444a795dd14339cb689a0e116e30b5fd
Signed-off-by: Karthik Anantha Ram <[email protected]>
Karthik Anantha Ram 2 years ago
parent
commit
8737f407d3

+ 36 - 25
drivers/cam_isp/cam_isp_context.c

@@ -116,6 +116,28 @@ static void __cam_isp_ctx_update_event_record(
 	ctx_isp->event_record[event][iterator].timestamp  = cur_time;
 }
 
+static int __cam_isp_ctx_handle_sof_freeze_evt(
+	struct cam_context *ctx)
+{
+	int rc = 0;
+	struct cam_isp_context      *ctx_isp;
+	struct cam_hw_cmd_args       hw_cmd_args;
+	struct cam_isp_hw_cmd_args   isp_hw_cmd_args;
+
+	ctx_isp = (struct cam_isp_context *)ctx->ctx_priv;
+	hw_cmd_args.ctxt_to_hw_map = ctx->ctxt_to_hw_map;
+	hw_cmd_args.cmd_type = CAM_HW_MGR_CMD_INTERNAL;
+	isp_hw_cmd_args.cmd_type = CAM_ISP_HW_MGR_CMD_SOF_DEBUG;
+	isp_hw_cmd_args.u.sof_irq_enable = 1;
+	hw_cmd_args.u.internal_args = (void *)&isp_hw_cmd_args;
+
+	rc = ctx->hw_mgr_intf->hw_cmd(ctx->hw_mgr_intf->hw_mgr_priv,
+		&hw_cmd_args);
+
+	ctx_isp->sof_dbg_irq_en = true;
+	return rc;
+}
+
 static void *cam_isp_ctx_user_dump_events(
 	void *dump_struct, uint8_t *addr_ptr)
 {
@@ -1369,10 +1391,11 @@ end:
 }
 
 static void __cam_isp_ctx_handle_buf_done_fail_log(
-	uint64_t request_id, struct cam_isp_ctx_req *req_isp,
-	uint32_t isp_device_type)
+	struct cam_isp_context *ctx_isp, uint64_t request_id,
+	struct cam_isp_ctx_req *req_isp)
 {
 	int i;
+	struct cam_context *ctx = ctx_isp->base;
 	const char *handle_type;
 
 	if (req_isp->num_fence_map_out >= CAM_ISP_CTX_RES_MAX) {
@@ -1391,7 +1414,8 @@ static void __cam_isp_ctx_handle_buf_done_fail_log(
 	for (i = 0; i < req_isp->num_fence_map_out; i++) {
 		if (req_isp->fence_map_out[i].sync_id != -1) {
 			handle_type = __cam_isp_resource_handle_id_to_type(
-				isp_device_type, req_isp->fence_map_out[i].resource_handle);
+				ctx_isp->isp_device_type,
+				req_isp->fence_map_out[i].resource_handle);
 
 			trace_cam_log_event("Buf_done Congestion",
 				handle_type, request_id, req_isp->fence_map_out[i].sync_id);
@@ -1403,6 +1427,9 @@ static void __cam_isp_ctx_handle_buf_done_fail_log(
 				req_isp->fence_map_out[i].sync_id);
 		}
 	}
+
+	if (!ctx_isp->sof_dbg_irq_en)
+		__cam_isp_ctx_handle_sof_freeze_evt(ctx);
 }
 
 static void __cam_isp_context_reset_internal_recovery_params(
@@ -1413,6 +1440,7 @@ static void __cam_isp_context_reset_internal_recovery_params(
 	ctx_isp->recovery_req_id = 0;
 	ctx_isp->aeb_error_cnt = 0;
 	ctx_isp->bubble_frame_cnt = 0;
+	ctx_isp->sof_dbg_irq_en = false;
 }
 
 static int __cam_isp_context_try_internal_recovery(
@@ -4430,9 +4458,8 @@ static int __cam_isp_ctx_apply_req_in_activated_state(
 		if (active_req) {
 			active_req_isp =
 				(struct cam_isp_ctx_req *) active_req->req_priv;
-			__cam_isp_ctx_handle_buf_done_fail_log(
-				active_req->request_id, active_req_isp,
-				ctx_isp->isp_device_type);
+			__cam_isp_ctx_handle_buf_done_fail_log(ctx_isp,
+				active_req->request_id, active_req_isp);
 		}
 
 		rc = -EFAULT;
@@ -5134,6 +5161,7 @@ static int __cam_isp_ctx_flush_req_in_top_state(
 
 end:
 	ctx_isp->bubble_frame_cnt = 0;
+	ctx_isp->sof_dbg_irq_en = false;
 	atomic_set(&ctx_isp->process_bubble, 0);
 	atomic_set(&ctx_isp->rxd_epoch, 0);
 	atomic_set(&ctx_isp->internal_recovery_set, 0);
@@ -7048,6 +7076,7 @@ static inline void __cam_isp_context_reset_ctx_params(
 	ctx_isp->bubble_frame_cnt = 0;
 	ctx_isp->recovery_req_id = 0;
 	ctx_isp->aeb_error_cnt = 0;
+	ctx_isp->sof_dbg_irq_en = false;
 }
 
 static int __cam_isp_ctx_start_dev_in_ready(struct cam_context *ctx,
@@ -7286,6 +7315,7 @@ static int __cam_isp_ctx_stop_dev_in_activated_unlock(
 	ctx_isp->last_applied_req_id = 0;
 	ctx_isp->req_info.last_bufdone_req_id = 0;
 	ctx_isp->bubble_frame_cnt = 0;
+	ctx_isp->sof_dbg_irq_en = false;
 	atomic_set(&ctx_isp->process_bubble, 0);
 	atomic_set(&ctx_isp->internal_recovery_set, 0);
 	atomic_set(&ctx_isp->rxd_epoch, 0);
@@ -7383,25 +7413,6 @@ static int __cam_isp_ctx_link_resume(struct cam_context *ctx)
 	return rc;
 }
 
-static int __cam_isp_ctx_handle_sof_freeze_evt(
-	struct cam_context *ctx)
-{
-	int rc = 0;
-	struct cam_hw_cmd_args       hw_cmd_args;
-	struct cam_isp_hw_cmd_args   isp_hw_cmd_args;
-
-	hw_cmd_args.ctxt_to_hw_map = ctx->ctxt_to_hw_map;
-	hw_cmd_args.cmd_type = CAM_HW_MGR_CMD_INTERNAL;
-	isp_hw_cmd_args.cmd_type = CAM_ISP_HW_MGR_CMD_SOF_DEBUG;
-	isp_hw_cmd_args.u.sof_irq_enable = 1;
-	hw_cmd_args.u.internal_args = (void *)&isp_hw_cmd_args;
-
-	rc = ctx->hw_mgr_intf->hw_cmd(ctx->hw_mgr_intf->hw_mgr_priv,
-		&hw_cmd_args);
-
-	return rc;
-}
-
 static int __cam_isp_ctx_reset_and_recover(
 	bool skip_resume, struct cam_context *ctx)
 {

+ 2 - 0
drivers/cam_isp/cam_isp_context.h

@@ -282,6 +282,7 @@ struct cam_isp_context_event_record {
  * @custom_enabled:            Custom HW enabled for this ctx
  * @use_frame_header_ts:       Use frame header for qtimer ts
  * @support_consumed_addr:     Indicate whether HW has last consumed addr reg
+ * @sof_dbg_irq_en:            Indicates whether ISP context has enabled debug irqs
  * @apply_in_progress          Whether request apply is in progress
  * @use_default_apply:         Use default settings in case of frame skip
  * @init_timestamp:            Timestamp at which this context is initialized
@@ -339,6 +340,7 @@ struct cam_isp_context {
 	bool                                  custom_enabled;
 	bool                                  use_frame_header_ts;
 	bool                                  support_consumed_addr;
+	bool                                  sof_dbg_irq_en;
 	atomic_t                              apply_in_progress;
 	atomic_t                              internal_recovery_set;
 	bool                                  use_default_apply;

+ 17 - 14
drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c

@@ -11801,27 +11801,30 @@ static int cam_ife_mgr_sof_irq_debug(
 	uint32_t sof_irq_enable)
 {
 	int rc = 0;
-	uint32_t i = 0;
+	uint32_t i = 0, hw_idx;
 	struct cam_isp_hw_mgr_res     *hw_mgr_res = NULL;
-	struct cam_hw_intf            *hw_intf = NULL;
 	struct cam_isp_resource_node  *rsrc_node = NULL;
+	struct cam_ife_hw_mgr *hw_mgr = ctx->hw_mgr;
 
-	list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_csid, list) {
-		for (i = 0; i < CAM_ISP_HW_SPLIT_MAX; i++) {
-			if (!hw_mgr_res->hw_res[i])
-				continue;
+	/* Per CSID enablement will enable for all paths */
+	for (i = 0; i < ctx->num_base; i++) {
+		if (ctx->base[i].hw_type != CAM_ISP_HW_TYPE_CSID)
+			continue;
 
-			hw_intf = hw_mgr_res->hw_res[i]->hw_intf;
-			if (hw_intf->hw_ops.process_cmd) {
-				rc |= hw_intf->hw_ops.process_cmd(
-					hw_intf->hw_priv,
-					CAM_IFE_CSID_SOF_IRQ_DEBUG,
-					&sof_irq_enable,
-					sizeof(sof_irq_enable));
-			}
+		hw_idx = ctx->base[i].idx;
+		if (hw_mgr->csid_devices[hw_idx]) {
+			rc |= hw_mgr->csid_devices[hw_idx]->hw_ops.process_cmd(
+				hw_mgr->csid_devices[hw_idx]->hw_priv,
+				CAM_IFE_CSID_SOF_IRQ_DEBUG,
+				&sof_irq_enable, sizeof(sof_irq_enable));
+			if (rc)
+				CAM_DBG(CAM_ISP,
+					"Failed to set CSID_%u sof irq debug cfg rc: %d",
+					hw_idx, rc);
 		}
 	}
 
+	/* legacy IFE CAMIF */
 	list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_src, list) {
 		for (i = 0; i < CAM_ISP_HW_SPLIT_MAX; i++) {
 			if (!hw_mgr_res->hw_res[i])

+ 9 - 7
drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_hw_ver2.c

@@ -265,7 +265,7 @@ static int cam_ife_csid_ver2_sof_irq_debug(
 	struct   cam_ife_csid_ver2_reg_info    *csid_reg;
 	struct   cam_ife_csid_ver2_path_cfg    *path_cfg;
 	struct   cam_isp_resource_node         *res;
-	uint32_t irq_mask[CAM_IFE_CSID_IRQ_REG_MAX] = {0};
+	uint32_t irq_mask = 0;
 	uint32_t data_idx;
 
 	if (*((uint32_t *)cmd_args) == 1)
@@ -293,12 +293,12 @@ static int cam_ife_csid_ver2_sof_irq_debug(
 		if (!path_cfg || !path_cfg->irq_handle)
 			continue;
 
-		irq_mask[path_cfg->irq_reg_idx] =
-			IFE_CSID_VER2_PATH_INFO_INPUT_SOF;
+		/* Assuming controller has only 1 register set */
+		irq_mask = IFE_CSID_VER2_PATH_INFO_INPUT_SOF;
 		cam_irq_controller_update_irq(
 			csid_hw->path_irq_controller[res->res_id],
 			path_cfg->irq_handle,
-			sof_irq_enable, irq_mask);
+			sof_irq_enable, &irq_mask);
 	}
 
 	if (sof_irq_enable) {
@@ -315,11 +315,13 @@ static int cam_ife_csid_ver2_sof_irq_debug(
 		csid_hw->hw_intf->hw_idx,
 		(sof_irq_enable) ? "enabled" : "disabled");
 
-	CAM_INFO(CAM_ISP, "Notify CSIPHY: %d",
+	if (sof_irq_enable) {
+		CAM_INFO(CAM_ISP, "Notify CSIPHY: %d",
 			csid_hw->rx_cfg.phy_sel - 1);
 
-	cam_subdev_notify_message(CAM_CSIPHY_DEVICE_TYPE,
-		CAM_SUBDEV_MESSAGE_REG_DUMP, (void *)&data_idx);
+		cam_subdev_notify_message(CAM_CSIPHY_DEVICE_TYPE,
+			CAM_SUBDEV_MESSAGE_REG_DUMP, (void *)&data_idx);
+	}
 
 	return 0;
 }