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

Commit 5d0da31f authored by Junzhe Zou's avatar Junzhe Zou Committed by Karthik Anantha Ram
Browse files

msm: camera: reject request id earlier than last flush request



UMD sends the last request id it expects to flush along with the
flush command and KMD saves it in its own structure. KMD should
recognize the request packets needed to be flushed according to the
request id and reject them.

Change-Id: I73547f0951a9bed4c402705f2f947041c7027d52
Signed-off-by: default avatarJunzhe Zou <jnzhezou@codeaurora.org>
parent c50f5867
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -448,6 +448,7 @@ int cam_context_handle_start_dev(struct cam_context *ctx,
	}

	mutex_lock(&ctx->ctx_mutex);
	ctx->last_flush_req = 0;
	if (ctx->state_machine[ctx->state].ioctl_ops.start_dev)
		rc = ctx->state_machine[ctx->state].ioctl_ops.start_dev(
			ctx, cmd);
+2 −0
Original line number Diff line number Diff line
@@ -180,6 +180,7 @@ struct cam_ctx_ops {
 * @refcount:              Context object refcount
 * @node:                  The main node to which this context belongs
 * @sync_mutex:            mutex to sync with sync cb thread
 * @last_flush_req:        Last request to flush
 *
 */
struct cam_context {
@@ -215,6 +216,7 @@ struct cam_context {
	struct kref                  refcount;
	void                        *node;
	struct mutex                 sync_mutex;
	uint32_t                     last_flush_req;
};

/**
+14 −2
Original line number Diff line number Diff line
@@ -326,6 +326,17 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,

	packet = (struct cam_packet *) (packet_addr + cmd->offset);

	if (packet->header.request_id <= ctx->last_flush_req) {
		CAM_DBG(CAM_CORE,
			"request %lld has been flushed, reject packet",
			packet->header.request_id);
		rc = -EINVAL;
		goto free_req;
	}

	if (packet->header.request_id > ctx->last_flush_req)
		ctx->last_flush_req = 0;

	/* preprocess the configuration */
	memset(&cfg, 0, sizeof(cfg));
	cfg.packet = packet;
@@ -811,9 +822,10 @@ int32_t cam_context_flush_dev_to_hw(struct cam_context *ctx,
		goto end;
	}

	if (cmd->flush_type == CAM_FLUSH_TYPE_ALL)
	if (cmd->flush_type == CAM_FLUSH_TYPE_ALL) {
		ctx->last_flush_req = cmd->req_id;
		rc = cam_context_flush_ctx_to_hw(ctx);
	else if (cmd->flush_type == CAM_FLUSH_TYPE_REQ)
	} else if (cmd->flush_type == CAM_FLUSH_TYPE_REQ)
		rc = cam_context_flush_req_to_hw(ctx, cmd);
	else {
		rc = -EINVAL;
+17 −0
Original line number Diff line number Diff line
@@ -1493,6 +1493,12 @@ static int __cam_isp_ctx_flush_req_in_top_state(
	struct cam_isp_start_args         start_isp;
	int rc = 0;

	if (flush_req->type == CAM_REQ_MGR_FLUSH_TYPE_ALL) {
		CAM_INFO(CAM_ISP, "Last request id to flush is %lld",
			flush_req->req_id);
		ctx->last_flush_req = flush_req->req_id;
	}

	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);
@@ -2232,6 +2238,17 @@ static int __cam_isp_ctx_config_dev_in_top_state(
	CAM_DBG(CAM_ISP, "Packet size 0x%x", packet->header.size);
	CAM_DBG(CAM_ISP, "packet op %d", packet->header.op_code);

	if (packet->header.request_id <= ctx->last_flush_req) {
		CAM_INFO(CAM_ISP,
			"request %lld has been flushed, reject packet",
			packet->header.request_id);
		rc = -EINVAL;
		goto free_req;
	}

	if (packet->header.request_id > ctx->last_flush_req)
		ctx->last_flush_req = 0;

	/* preprocess the configuration */
	memset(&cfg, 0, sizeof(cfg));
	cfg.packet = packet;
+15 −0
Original line number Diff line number Diff line
@@ -1494,6 +1494,9 @@ int cam_req_mgr_process_flush_req(void *priv, void *data)

	mutex_lock(&link->req.lock);
	if (flush_info->flush_type == CAM_REQ_MGR_FLUSH_TYPE_ALL) {
		link->last_flush_id = flush_info->req_id;
		CAM_INFO(CAM_CRM, "Last request id to flush is %lld",
			flush_info->req_id);
		for (i = 0; i < in_q->num_slots; i++) {
			slot = &in_q->slot[i];
			slot->req_id = -1;
@@ -2422,6 +2425,7 @@ int cam_req_mgr_link(struct cam_req_mgr_link_info *link_info)
		goto link_hdl_fail;
	}
	link_info->link_hdl = link->link_hdl;
	link->last_flush_id = 0;

	/* Allocate memory to hold data of all linked devs */
	rc = __cam_req_mgr_create_subdevs(&link->l_dev,
@@ -2547,6 +2551,17 @@ int cam_req_mgr_schedule_request(
		goto end;
	}

	if (sched_req->req_id <= link->last_flush_id) {
		CAM_INFO(CAM_CRM,
			"request %d is flushed, last_flush_id to flush %lld",
			sched_req->req_id, link->last_flush_id);
		rc = -EINVAL;
		goto end;
	}

	if (sched_req->req_id > link->last_flush_id)
		link->last_flush_id = 0;

	CAM_DBG(CAM_CRM, "link 0x%x req %lld, sync_mode %d",
		sched_req->link_hdl, sched_req->req_id, sched_req->sync_mode);

Loading