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

Commit e51b895c authored by Trishansh Bhardwaj's avatar Trishansh Bhardwaj Committed by Gerrit - the friendly Code Review server
Browse files

msm: camera: isp: Fix race condition b/w add and apply req



There is a chance that CRM shows request as ready while request is not
passed in isp pending list.

Change-Id: I0056b09b31d78629957ba196d148f1b308205753
Signed-off-by: default avatarTrishansh Bhardwaj <tbhardwa@codeaurora.org>
parent 5b31de59
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -124,6 +124,24 @@ static void __cam_isp_ctx_dump_state_monitor_array(
	}
}

static int __cam_isp_ctx_dequeue_request(struct cam_context *ctx,
	struct cam_ctx_request *req)
{
	struct cam_ctx_request           *req_current;
	struct cam_ctx_request           *req_prev;

	spin_lock_bh(&ctx->lock);
	list_for_each_entry_safe_reverse(req_current, req_prev,
		&ctx->pending_req_list, list) {
		if (req->request_id == req_current->request_id) {
			list_del_init(&req_current->list);
			break;
		}
	}
	spin_unlock_bh(&ctx->lock);
	return 0;
}

static int __cam_isp_ctx_enqueue_request_in_order(
	struct cam_context *ctx, struct cam_ctx_request *req)
{
@@ -2193,13 +2211,12 @@ static int __cam_isp_ctx_config_dev_in_top_state(
			add_req.dev_hdl  = ctx->dev_hdl;
			add_req.req_id   = req->request_id;
			add_req.skip_before_applying = 0;
			__cam_isp_ctx_enqueue_request_in_order(ctx, req);
			rc = ctx->ctx_crm_intf->add_req(&add_req);
			if (rc) {
				CAM_ERR(CAM_ISP, "Add req failed: req id=%llu",
					req->request_id);
			} else {
				__cam_isp_ctx_enqueue_request_in_order(
					ctx, req);
				__cam_isp_ctx_dequeue_request(ctx, req);
			}
		} else {
			rc = -EINVAL;