Эх сурвалжийг харах

msm: camera: reqmgr: Update the logic for workqueue congestion detection

This change uses half frame interval as workqueue congestion
detection threshold and record the last trigger time before
sending req, we can get correct last tirgger time in this way.

CRs-Fixed: 3237172
Change-Id: I2d583f7758062340fe6b0c598bfa7e90f49211c2
Signed-off-by: Depeng Shao <[email protected]>
Depeng Shao 3 жил өмнө
parent
commit
9259524769

+ 15 - 8
drivers/cam_req_mgr/cam_req_mgr_core.c

@@ -1871,6 +1871,7 @@ static int __cam_req_mgr_process_req(struct cam_req_mgr_core_link *link,
 	int                                  rc = 0, idx, i;
 	int                                  reset_step = 0;
 	uint32_t                             trigger = trigger_data->trigger;
+	uint64_t                             wq_sched_timeout = 0;
 	struct cam_req_mgr_slot             *slot = NULL;
 	struct cam_req_mgr_req_queue        *in_q;
 	struct cam_req_mgr_core_session     *session;
@@ -1944,13 +1945,26 @@ static int __cam_req_mgr_process_req(struct cam_req_mgr_core_link *link,
 		link->prev_sof_timestamp = link->sof_timestamp;
 		link->sof_timestamp = trigger_data->sof_timestamp_val;
 
+		/* Use half frame interval to detect the WQ congestion */
+		wq_sched_timeout = CAM_REQ_MGR_HALF_FRAME_DURATION(link->sof_timestamp -
+			link->prev_sof_timestamp) / CAM_COMMON_NS_PER_MS;
+
 		/* Check for WQ congestion */
 		if (jiffies_to_msecs(jiffies -
 			link->last_sof_trigger_jiffies) <
-			MINIMUM_WORKQUEUE_SCHED_TIME_IN_MS)
+			wq_sched_timeout)
 			link->wq_congestion = true;
 		else
 			link->wq_congestion = false;
+
+		/*
+		 * Only update the jiffies for SOF trigger,
+		 * since it is used to protect from
+		 * applying fails in ISP which is triggered at SOF.
+		 */
+		if (trigger == CAM_TRIGGER_POINT_SOF)
+			link->last_sof_trigger_jiffies = jiffies;
+
 	}
 
 	if (slot->status != CRM_SLOT_STATUS_REQ_READY) {
@@ -2137,13 +2151,6 @@ static int __cam_req_mgr_process_req(struct cam_req_mgr_core_link *link,
 		}
 	}
 end:
-	/*
-	 * Only update the jiffies for SOF trigger,
-	 * since it is used to protect from
-	 * applying fails in ISP which is triggered at SOF.
-	 */
-	if (trigger == CAM_TRIGGER_POINT_SOF)
-		link->last_sof_trigger_jiffies = jiffies;
 	mutex_unlock(&session->lock);
 	return rc;
 }

+ 2 - 2
drivers/cam_req_mgr/cam_req_mgr_core.h

@@ -41,12 +41,12 @@
 
 #define MAXIMUM_RETRY_ATTEMPTS 3
 
-#define MINIMUM_WORKQUEUE_SCHED_TIME_IN_MS 5
-
 #define VERSION_1  1
 #define VERSION_2  2
 #define CAM_REQ_MGR_MAX_TRIGGERS   2
 
+#define CAM_REQ_MGR_HALF_FRAME_DURATION(frame_duration) (frame_duration / 2)
+
 /**
  * enum crm_req_eof_trigger_type
  * @codes: to identify which type of eof trigger for next slot

+ 2 - 0
drivers/cam_utils/cam_common_util.h

@@ -29,6 +29,8 @@
 #define CAM_COMMON_ICP_NODE "IPE"
 #define CAM_COMMON_JPEG_NODE "JPEG"
 
+#define CAM_COMMON_NS_PER_MS              1000000ULL
+
 #define PTR_TO_U64(ptr) ((uint64_t)(uintptr_t)ptr)
 #define U64_TO_PTR(ptr) ((void *)(uintptr_t)ptr)