Pārlūkot izejas kodu

msm: camera: isp: Add atomic flag instead of wait in handle error

Errors in isp are handled in soft irq context, putting a wait for
cdm done is not allowed. Add atomic flag for checking status of
cdm and check it before reg dump to determine the request for
which register values can be dumped in command buffer.This is
only applicable to reg dump on error.

CRs-Fixed: 2510557
Change-Id: If4bfedd1a62078392721c2ea0958da82087f5b26
Signed-off-by: Mukund Madhusudan Atre <[email protected]>
Mukund Madhusudan Atre 5 gadi atpakaļ
vecāks
revīzija
b582eeddce

+ 15 - 10
drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c

@@ -2078,6 +2078,7 @@ void cam_ife_cam_cdm_callback(uint32_t handle, void *userdata,
 
 	if (status == CAM_CDM_CB_STATUS_BL_SUCCESS) {
 		complete_all(&ctx->config_done_complete);
+		atomic_set(&ctx->cdm_done, 1);
 		CAM_DBG(CAM_ISP,
 			"Called by CDM hdl=%x, udata=%pK, status=%d, cookie=%llu ctx_index=%d",
 			 handle, userdata, status, cookie, ctx->ctx_index);
@@ -3063,6 +3064,7 @@ static int cam_ife_mgr_config_hw(void *hw_mgr_priv,
 		ctx->applied_req_id = cfg->request_id;
 
 		CAM_DBG(CAM_ISP, "Submit to CDM");
+		atomic_set(&ctx->cdm_done, 0);
 		rc = cam_cdm_submit_bls(ctx->cdm_handle, cdm_cmd);
 		if (rc) {
 			CAM_ERR(CAM_ISP, "Failed to apply the configs");
@@ -5371,15 +5373,9 @@ static int cam_ife_mgr_handle_reg_dump(struct cam_ife_hw_mgr_ctx *ctx,
 		return 0;
 	}
 
-	rc = wait_for_completion_timeout(
-		&ctx->config_done_complete,
-		msecs_to_jiffies(30));
-	if (rc <= 0) {
-		CAM_ERR(CAM_ISP,
-			"config done completion timeout rc=%d ctx_index %d",
-			rc, ctx->ctx_index);
-		rc = 0;
-	}
+	if (!atomic_read(&ctx->cdm_done))
+		CAM_WARN_RATE_LIMIT(CAM_ISP,
+			"Reg dump values might be from more than one request");
 
 	for (i = 0; i < ctx->num_reg_dump_buf; i++) {
 		CAM_DBG(CAM_ISP, "Reg dump cmd meta data: %d req_type: %d",
@@ -5468,8 +5464,17 @@ static int cam_ife_mgr_cmd(void *hw_mgr_priv, void *cmd_args)
 		if (ctx->last_dump_flush_req_id == ctx->applied_req_id)
 			return 0;
 
-		ctx->last_dump_flush_req_id = ctx->applied_req_id;
+		rc = wait_for_completion_timeout(
+			&ctx->config_done_complete,
+			msecs_to_jiffies(30));
+		if (rc <= 0) {
+			CAM_ERR(CAM_ISP,
+				"config done completion timeout, Reg dump will be unreliable rc=%d ctx_index %d",
+				rc, ctx->ctx_index);
+			rc = 0;
+		}
 
+		ctx->last_dump_flush_req_id = ctx->applied_req_id;
 		rc = cam_ife_mgr_handle_reg_dump(ctx,
 			CAM_ISP_PACKET_META_REG_DUMP_ON_FLUSH);
 		if (rc) {

+ 3 - 0
drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h

@@ -122,6 +122,8 @@ struct cam_ife_hw_mgr_debug {
  * @eof_cnt                 eof count value per core, used for dual VFE
  * @overflow_pending        flat to specify the overflow is pending for the
  *                          context
+ * @cdm_done                flag to indicate cdm has finished writing shadow
+ *                          registers
  * @is_rdi_only_context     flag to specify the context has only rdi resource
  * @config_done_complete    indicator for configuration complete
  * @reg_dump_buf_desc:      cmd buffer descriptors for reg dump
@@ -164,6 +166,7 @@ struct cam_ife_hw_mgr_ctx {
 	uint32_t                        epoch_cnt[CAM_IFE_HW_NUM_MAX];
 	uint32_t                        eof_cnt[CAM_IFE_HW_NUM_MAX];
 	atomic_t                        overflow_pending;
+	atomic_t                        cdm_done;
 	uint32_t                        is_rdi_only_context;
 	struct completion               config_done_complete;
 	struct cam_cmd_buf_desc         reg_dump_buf_desc[