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

Commit 376b4d3f authored by Karthik Anantha Ram's avatar Karthik Anantha Ram Committed by Gerrit - the friendly Code Review server
Browse files

msm: camera: reqmgr: Correct the check for lower pd devices



If no new req is pending in slot, finish the lower pipeline
delay devices with available req ids. There is possibility that
there is no lower pd devices on a given link and we will
modify the rd_idx & wr_idx incorrectly hence added validation
to avoid this.

Change-Id: Iaef5e72397ea6b341d4716127f1e013df63293b8
Signed-off-by: default avatarKarthik Anantha Ram <kartanan@codeaurora.org>
parent 6cfce279
Loading
Loading
Loading
Loading
+48 −5
Original line number Diff line number Diff line
@@ -364,6 +364,30 @@ static void __cam_req_mgr_reset_req_slot(struct cam_req_mgr_core_link *link,
	}
}

/**
 * __cam_req_mgr_check_for_lower_pd_devices()
 *
 * @brief    : Checks if there are any devices on the link having a lesser
 *             pd than the max pd of the link
 * @link     : Pointer to link which needs to be checked
 *
 * @return   : 0 if a lower pd device is found negative otherwise
 */
static int __cam_req_mgr_check_for_lower_pd_devices(
	struct cam_req_mgr_core_link	*link)
{
	int i = 0;
	struct cam_req_mgr_connected_device *dev = NULL;

	for (i = 0; i < link->num_devs; i++) {
		dev = &link->l_dev[i];
		if (dev->dev_info.p_delay < link->max_delay)
			return 0;
	}

	return -EAGAIN;
}

/**
 * __cam_req_mgr_check_next_req_slot()
 *
@@ -372,10 +396,13 @@ static void __cam_req_mgr_reset_req_slot(struct cam_req_mgr_core_link *link,
 *             devices with lower pipeline delay value.
 * @in_q     : Pointer to input queue where req mgr wil peep into
 *
 * @return   : 0 for success, negative for failure
 */
static void __cam_req_mgr_check_next_req_slot(
	struct cam_req_mgr_req_queue *in_q)
static int __cam_req_mgr_check_next_req_slot(
	struct cam_req_mgr_core_link *link)
{
	int rc = 0;
	struct cam_req_mgr_req_queue *in_q = link->req.in_q;
	int32_t idx = in_q->rd_idx;
	struct cam_req_mgr_slot *slot;

@@ -386,12 +413,20 @@ static void __cam_req_mgr_check_next_req_slot(

	/* Check if there is new req from CSL, if not complete req */
	if (slot->status == CRM_SLOT_STATUS_NO_REQ) {
		rc = __cam_req_mgr_check_for_lower_pd_devices(link);
		if (rc) {
			CAM_DBG(CAM_CRM, "No lower pd devices on link 0x%x",
				link->link_hdl);
			return rc;
		}
		__cam_req_mgr_in_q_skip_idx(in_q, idx);
		if (in_q->wr_idx != idx)
			CAM_WARN(CAM_CRM,
				"CHECK here wr %d, rd %d", in_q->wr_idx, idx);
		__cam_req_mgr_inc_idx(&in_q->wr_idx, 1, in_q->num_slots);
	}

	return rc;
}

/**
@@ -2032,12 +2067,20 @@ static int cam_req_mgr_process_trigger(void *priv, void *data)
		 */
		CAM_DBG(CAM_CRM, "link[%x] Req[%lld] invalidating slot",
			link->link_hdl, in_q->slot[in_q->rd_idx].req_id);
		__cam_req_mgr_check_next_req_slot(in_q);
		rc = __cam_req_mgr_check_next_req_slot(link);
		if (rc) {
			CAM_DBG(CAM_REQ,
				"No pending req to apply to lower pd devices");
			rc = 0;
			goto release_lock;
		}
		__cam_req_mgr_inc_idx(&in_q->rd_idx, 1, in_q->num_slots);
	}

	rc = __cam_req_mgr_process_req(link, trigger_data->trigger);
	mutex_unlock(&link->req.lock);

release_lock:
	mutex_unlock(&link->req.lock);
end:
	return rc;
}