Browse Source

Merge "msm: camera: isp: Add more deferred buf done support" into camera-kernel.lnx.5.0

Camera Software Integration 3 năm trước cách đây
mục cha
commit
2be5d43313
1 tập tin đã thay đổi với 48 bổ sung6 xóa
  1. 48 6
      drivers/cam_isp/cam_isp_context.c

+ 48 - 6
drivers/cam_isp/cam_isp_context.c

@@ -2006,17 +2006,16 @@ static int __cam_isp_ctx_handle_buf_done_verify_addr(
 	struct cam_ctx_request *req;
 	struct cam_ctx_request *req;
 	struct cam_ctx_request *next_req = NULL;
 	struct cam_ctx_request *next_req = NULL;
 	struct cam_context *ctx = ctx_isp->base;
 	struct cam_context *ctx = ctx_isp->base;
-	bool  req_in_wait_list = false;
+	struct cam_isp_ctx_req *req_isp;
+	bool  req_in_pending_wait_list = false;
 
 
 	if (list_empty(&ctx->active_req_list)) {
 	if (list_empty(&ctx->active_req_list)) {
 
 
 		if (!list_empty(&ctx->wait_req_list)) {
 		if (!list_empty(&ctx->wait_req_list)) {
-			struct cam_isp_ctx_req *req_isp;
-
 			req = list_first_entry(&ctx->wait_req_list,
 			req = list_first_entry(&ctx->wait_req_list,
 				struct cam_ctx_request, list);
 				struct cam_ctx_request, list);
 
 
-			req_in_wait_list = true;
+			req_in_pending_wait_list = true;
 			if (ctx_isp->last_applied_req_id !=
 			if (ctx_isp->last_applied_req_id !=
 				ctx_isp->last_bufdone_err_apply_req_id) {
 				ctx_isp->last_bufdone_err_apply_req_id) {
 				CAM_WARN(CAM_ISP,
 				CAM_WARN(CAM_ISP,
@@ -2030,6 +2029,39 @@ static int __cam_isp_ctx_handle_buf_done_verify_addr(
 
 
 			req_isp = (struct cam_isp_ctx_req *) req->req_priv;
 			req_isp = (struct cam_isp_ctx_req *) req->req_priv;
 
 
+			/*
+			 * Verify consumed address for this request to make sure
+			 * we are handling the buf_done for the correct
+			 * buffer. Also defer actual buf_done handling, i.e
+			 * do not signal the fence as this request may go into
+			 * Bubble state eventully.
+			 */
+			rc =
+			__cam_isp_ctx_handle_buf_done_for_request_verify_addr(
+				ctx_isp, req, done, bubble_state, true, true);
+		} else if (!list_empty(&ctx->pending_req_list)) {
+			/*
+			 * We saw the case that the hw config is blocked due to
+			 * some reason, the we get the reg upd and buf done before
+			 * the req is added to wait req list.
+			 */
+			req = list_first_entry(&ctx->pending_req_list,
+				struct cam_ctx_request, list);
+
+			req_in_pending_wait_list = true;
+			if (ctx_isp->last_applied_req_id !=
+				ctx_isp->last_bufdone_err_apply_req_id) {
+				CAM_WARN(CAM_ISP,
+					"Buf done with no active request but with req in pending list, req %llu last apply id:%lld last err id:%lld",
+					req->request_id,
+					ctx_isp->last_applied_req_id,
+					ctx_isp->last_bufdone_err_apply_req_id);
+				ctx_isp->last_bufdone_err_apply_req_id =
+					ctx_isp->last_applied_req_id;
+			}
+
+			req_isp = (struct cam_isp_ctx_req *) req->req_priv;
+
 			/*
 			/*
 			 * Verify consumed address for this request to make sure
 			 * Verify consumed address for this request to make sure
 			 * we are handling the buf_done for the correct
 			 * we are handling the buf_done for the correct
@@ -2042,7 +2074,7 @@ static int __cam_isp_ctx_handle_buf_done_verify_addr(
 				ctx_isp, req, done, bubble_state, true, true);
 				ctx_isp, req, done, bubble_state, true, true);
 		}
 		}
 
 
-		if (!req_in_wait_list  && (ctx_isp->last_applied_req_id !=
+		if (!req_in_pending_wait_list  && (ctx_isp->last_applied_req_id !=
 			ctx_isp->last_bufdone_err_apply_req_id)) {
 			ctx_isp->last_bufdone_err_apply_req_id)) {
 			CAM_WARN(CAM_ISP,
 			CAM_WARN(CAM_ISP,
 				"Buf done with no active request bubble_state=%d last_applied_req_id:%lld ",
 				"Buf done with no active request bubble_state=%d last_applied_req_id:%lld ",
@@ -2687,6 +2719,16 @@ end:
 	return 0;
 	return 0;
 }
 }
 
 
+static int __cam_isp_ctx_buf_done_in_sof(struct cam_isp_context *ctx_isp,
+	void *evt_data)
+{
+	int rc = 0;
+	struct cam_isp_hw_done_event_data *done =
+		(struct cam_isp_hw_done_event_data *) evt_data;
+
+	rc = __cam_isp_ctx_handle_buf_done_in_activated_state(ctx_isp, done, 0);
+	return rc;
+}
 
 
 static int __cam_isp_ctx_buf_done_in_applied(struct cam_isp_context *ctx_isp,
 static int __cam_isp_ctx_buf_done_in_applied(struct cam_isp_context *ctx_isp,
 	void *evt_data)
 	void *evt_data)
@@ -3548,7 +3590,7 @@ static struct cam_isp_ctx_irq_ops
 			__cam_isp_ctx_reg_upd_in_sof,
 			__cam_isp_ctx_reg_upd_in_sof,
 			__cam_isp_ctx_notify_sof_in_activated_state,
 			__cam_isp_ctx_notify_sof_in_activated_state,
 			__cam_isp_ctx_notify_eof_in_activated_state,
 			__cam_isp_ctx_notify_eof_in_activated_state,
-			NULL,
+			__cam_isp_ctx_buf_done_in_sof,
 			__cam_isp_ctx_handle_secondary_events,
 			__cam_isp_ctx_handle_secondary_events,
 		},
 		},
 	},
 	},