Browse Source

msm: camera: isp: Add check to prevent duplicate deferred ack increment

Due to the scheduling delay, the top half was getting delayed for
buff-done events. 2 different requests buff-done is merged due to
top half delay and we incremented 2 times deferred ack due to merger
of buff-done events. This check will prevent duplicate deferred
ack increments.

CRs-Fixed: 3477436
Change-Id: If6bbd460a0a1025758f330f26eaf1099de2daa38
Signed-off-by: Chandan Kumar Jha <[email protected]>
Chandan Kumar Jha 2 years ago
parent
commit
9417997bb2
1 changed files with 28 additions and 1 deletions
  1. 28 1
      drivers/cam_isp/cam_isp_context.c

+ 28 - 1
drivers/cam_isp/cam_isp_context.c

@@ -2087,7 +2087,8 @@ static int __cam_isp_ctx_handle_buf_done_for_request_verify_addr(
 	bool defer_buf_done)
 {
 	int rc = 0;
-	int i, j;
+	int i, j, k, def_idx;
+	bool duplicate_defer_buf_done = false;
 	struct cam_isp_ctx_req *req_isp;
 	struct cam_context *ctx = ctx_isp->base;
 	const char *handle_type;
@@ -2198,6 +2199,32 @@ static int __cam_isp_ctx_handle_buf_done_for_request_verify_addr(
 
 		if (defer_buf_done) {
 			uint32_t deferred_indx = req_isp->num_deferred_acks;
+			duplicate_defer_buf_done = false;
+
+			for (k = 0; k < req_isp->num_deferred_acks; k++) {
+				def_idx = req_isp->deferred_fence_map_index[k];
+				if (def_idx == j) {
+					CAM_WARN(CAM_ISP,
+						"duplicate deferred ack for ctx[%u] link[0x%x] req %lld res 0x%x sync_id 0x%x",
+						ctx->ctx_id, ctx->link_hdl,
+						req->request_id,
+						req_isp->fence_map_out[j].resource_handle,
+						req_isp->fence_map_out[j].sync_id);
+					duplicate_defer_buf_done = true;
+					break;
+				}
+			}
+
+			if (duplicate_defer_buf_done)
+				continue;
+
+			if (req_isp->num_deferred_acks == req_isp->num_fence_map_out) {
+				CAM_WARN(CAM_ISP,
+					"WARNING: req_id %lld num_deferred_acks %d > map_out %d, ctx_idx:%u link[0x%x]",
+					req->request_id, req_isp->num_deferred_acks,
+					req_isp->num_fence_map_out, ctx->ctx_id, ctx->link_hdl);
+				continue;
+			}
 
 			/*
 			 * If we are handling this BUF_DONE event for a request