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

Commit f4e828e2 authored by Depeng Shao's avatar Depeng Shao Committed by Ziyu Jian
Browse files

msm: camera: reqmgr: Add protection for workqueue congestion



When workqueue is congested, CRM may apply same
request to device which will trigger recovery
due to apply fails. This change prevent CRM
triggering recovery if the time interval of
continuous applying req less than 5ms.

CRs-Fixed: 2775372
Change-Id: I45c2ed76334b1bbf4547bbf21f90cf0a6c169323
Signed-off-by: default avatarDepeng Shao <depengs@codeaurora.org>
parent 4ae94979
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ void cam_req_mgr_core_link_reset(struct cam_req_mgr_core_link *link)
	link->sof_timestamp = 0;
	link->prev_sof_timestamp = 0;
	link->skip_wd_validation = false;
	link->last_applied_jiffies = 0;
}

void cam_req_mgr_handle_core_shutdown(void)
@@ -1376,6 +1377,7 @@ static int __cam_req_mgr_process_req(struct cam_req_mgr_core_link *link,
{
	int                                  rc = 0, idx;
	int                                  reset_step = 0;
	bool                                 check_retry_cnt = false;
	uint32_t                             trigger = trigger_data->trigger;
	struct cam_req_mgr_slot             *slot = NULL;
	struct cam_req_mgr_req_queue        *in_q;
@@ -1495,9 +1497,15 @@ static int __cam_req_mgr_process_req(struct cam_req_mgr_core_link *link,

	rc = __cam_req_mgr_send_req(link, link->req.in_q, trigger, &dev);
	if (rc < 0) {
		if (in_q->last_applied_idx < in_q->rd_idx) {
		/* Apply req failed retry at next sof */
		slot->status = CRM_SLOT_STATUS_REQ_PENDING;

		if (jiffies_to_msecs(jiffies - link->last_applied_jiffies) >
			MINIMUM_WORKQUEUE_SCHED_TIME_IN_MS)
			check_retry_cnt = true;

		if ((in_q->last_applied_idx < in_q->rd_idx) &&
			check_retry_cnt) {
			link->retry_cnt++;
			max_retry = MAXIMUM_RETRY_ATTEMPTS;
			if (link->max_delay == 1)
@@ -1563,6 +1571,16 @@ static int __cam_req_mgr_process_req(struct cam_req_mgr_core_link *link,
		}
	}

	/*
	 * Only update the jiffies of last applied request
	 * for SOF trigger, since it is used to protect from
	 * applying fails in ISP which is triggered at SOF.
	 * And, also don't need to do update for error case
	 * since error case doesn't check the retry count.
	 */
	if (trigger == CAM_TRIGGER_POINT_SOF)
		link->last_applied_jiffies = jiffies;

	mutex_unlock(&session->lock);
	return rc;
error:
+4 −1
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@

#define MAXIMUM_RETRY_ATTEMPTS 2

#define MINIMUM_WORKQUEUE_SCHED_TIME_IN_MS 5

#define VERSION_1  1
#define VERSION_2  2
#define CAM_REQ_MGR_MAX_TRIGGERS   2
@@ -351,6 +353,7 @@ struct cam_req_mgr_connected_device {
 * @trigger_cnt          : trigger count value per device initiating the trigger
 * @skip_wd_validation   : skip initial frames crm_wd_timer validation in the
 *                         case of long exposure use case
 * @last_applied_jiffies : Record the jiffies of last applied req
 */
struct cam_req_mgr_core_link {
	int32_t                              link_hdl;
@@ -384,7 +387,7 @@ struct cam_req_mgr_core_link {
	bool                                 dual_trigger;
	uint32_t    trigger_cnt[CAM_REQ_MGR_MAX_TRIGGERS];
	bool                                 skip_wd_validation;

	uint64_t                             last_applied_jiffies;
};

/**