Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1fbea0eb authored by Venkat Chinta's avatar Venkat Chinta Committed by Gerrit - the friendly Code Review server
Browse files

msm: camera: isp: Change context lock acquire sequence in flush



Move acquiring context lock to functions calling flush to prevent
race conditions.

Change-Id: Ic30ae8c3d8cd477bf719803c39360e47a0b02811
Signed-off-by: default avatarVenkat Chinta <vchinta@codeaurora.org>
parent 54d836a4
Loading
Loading
Loading
Loading
+6 −8
Original line number Diff line number Diff line
@@ -1324,9 +1324,7 @@ static int __cam_isp_ctx_flush_req(struct cam_context *ctx,
	struct list_head                  flush_list;

	INIT_LIST_HEAD(&flush_list);
	spin_lock_bh(&ctx->lock);
	if (list_empty(req_list)) {
		spin_unlock_bh(&ctx->lock);
		CAM_DBG(CAM_ISP, "request list is empty");
		return 0;
	}
@@ -1345,7 +1343,6 @@ static int __cam_isp_ctx_flush_req(struct cam_context *ctx,
		list_del_init(&req->list);
		list_add_tail(&req->list, &flush_list);
	}
	spin_unlock_bh(&ctx->lock);

	list_for_each_entry_safe(req, req_temp, &flush_list, list) {
		req_isp = (struct cam_isp_ctx_req *) req->req_priv;
@@ -1363,9 +1360,7 @@ static int __cam_isp_ctx_flush_req(struct cam_context *ctx,
				req_isp->fence_map_out[i].sync_id = -1;
			}
		}
		spin_lock_bh(&ctx->lock);
		list_add_tail(&req->list, &ctx->free_req_list);
		spin_unlock_bh(&ctx->lock);
	}

	if (flush_req->type == CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ &&
@@ -1384,7 +1379,9 @@ static int __cam_isp_ctx_flush_req_in_top_state(
	int rc = 0;

	CAM_DBG(CAM_ISP, "try to flush pending list");
	spin_lock_bh(&ctx->lock);
	rc = __cam_isp_ctx_flush_req(ctx, &ctx->pending_req_list, flush_req);
	spin_unlock_bh(&ctx->lock);
	CAM_DBG(CAM_ISP, "Flush request in top state %d",
		 ctx->state);
	return rc;
@@ -1401,10 +1398,10 @@ static int __cam_isp_ctx_flush_req_in_activated(
	spin_lock_bh(&ctx->lock);
	ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_FLUSH;
	ctx_isp->frame_skip_count = 2;
	spin_unlock_bh(&ctx->lock);

	CAM_DBG(CAM_ISP, "Flush request in state %d", ctx->state);
	rc = __cam_isp_ctx_flush_req(ctx, &ctx->pending_req_list, flush_req);
	spin_unlock_bh(&ctx->lock);
	return rc;
}

@@ -1415,10 +1412,10 @@ static int __cam_isp_ctx_flush_req_in_ready(
	int rc = 0;

	CAM_DBG(CAM_ISP, "try to flush pending list");
	spin_lock_bh(&ctx->lock);
	rc = __cam_isp_ctx_flush_req(ctx, &ctx->pending_req_list, flush_req);

	/* if nothing is in pending req list, change state to acquire*/
	spin_lock_bh(&ctx->lock);
	if (list_empty(&ctx->pending_req_list))
		ctx->state = CAM_CTX_ACQUIRED;
	spin_unlock_bh(&ctx->lock);
@@ -1994,8 +1991,9 @@ static int __cam_isp_ctx_release_dev_in_top_state(struct cam_context *ctx,
	flush_req.dev_hdl = ctx->dev_hdl;

	CAM_DBG(CAM_ISP, "try to flush pending list");
	spin_lock_bh(&ctx->lock);
	rc = __cam_isp_ctx_flush_req(ctx, &ctx->pending_req_list, &flush_req);

	spin_unlock_bh(&ctx->lock);
	ctx->state = CAM_CTX_AVAILABLE;

	trace_cam_context_state("ISP", ctx);