ソースを参照

Merge "msm: camera: reqmgr: Correct the count decrement logic" into camera-kernel.lnx.5.0

Camera Software Integration 4 年 前
コミット
4eb55453f1

+ 24 - 6
drivers/cam_req_mgr/cam_req_mgr_core.c

@@ -29,6 +29,7 @@ void cam_req_mgr_core_link_reset(struct cam_req_mgr_core_link *link)
 	link->link_hdl = 0;
 	link->num_devs = 0;
 	link->max_delay = CAM_PIPELINE_DELAY_0;
+	link->min_delay = CAM_PIPELINE_DELAY_MAX;
 	link->workq = NULL;
 	link->pd_mask = 0;
 	link->l_dev = NULL;
@@ -227,12 +228,12 @@ static void __cam_req_mgr_find_dev_name(
 				continue;
 			if (link->wq_congestion)
 				CAM_INFO_RATE_LIMIT(CAM_CRM,
-					"WQ congestion, Skip Frame: req: %lld not ready on link: 0x%x for pd: %d dev: %s open_req count: %d",
+					"WQ congestion, Skip Frame: req: %lld not ready on link: 0x%x for pd: %d dev: %s open_req count: %u",
 					req_id, link->link_hdl, pd,
 					dev->dev_info.name, link->open_req_cnt);
 			else
 				CAM_INFO(CAM_CRM,
-					"Skip Frame: req: %lld not ready on link: 0x%x for pd: %d dev: %s open_req count: %d",
+					"Skip Frame: req: %lld not ready on link: 0x%x for pd: %d dev: %s open_req count: %u",
 					req_id, link->link_hdl, pd,
 					dev->dev_info.name, link->open_req_cnt);
 		}
@@ -813,6 +814,7 @@ static int __cam_req_mgr_send_req(struct cam_req_mgr_core_link *link,
 	struct cam_req_mgr_connected_device **failed_dev)
 {
 	int                                  rc = 0, pd, i, idx;
+	bool                                 req_applied_to_min_pd = false;
 	struct cam_req_mgr_connected_device *dev = NULL;
 	struct cam_req_mgr_apply_request     apply_req;
 	struct cam_req_mgr_link_evt_data     evt_data;
@@ -1014,6 +1016,10 @@ static int __cam_req_mgr_send_req(struct cam_req_mgr_core_link *link,
 					break;
 				}
 			}
+
+			if (pd == link->min_delay)
+				req_applied_to_min_pd = true;
+
 			trace_cam_req_mgr_apply_request(link, &apply_req, dev);
 		}
 	}
@@ -1036,6 +1042,12 @@ static int __cam_req_mgr_send_req(struct cam_req_mgr_core_link *link,
 		memcpy(link->req.prev_apply_data, link->req.apply_data,
 			CAM_PIPELINE_DELAY_MAX *
 			sizeof(struct cam_req_mgr_apply));
+		if (req_applied_to_min_pd) {
+			link->open_req_cnt--;
+			CAM_DBG(CAM_REQ,
+				"Open_reqs: %u after successfully applying req:%d",
+				link->open_req_cnt, apply_req.request_id);
+		}
 	}
 
 	return rc;
@@ -1194,7 +1206,7 @@ static int __cam_req_mgr_check_sync_for_mslave(
 	sync_rd_idx = sync_link->req.in_q->rd_idx;
 
 	CAM_DBG(CAM_CRM,
-		"link_hdl %x req %lld frame_skip_flag %d open_req_cnt:%d initial_sync_req [%lld,%lld] is_master:%d",
+		"link_hdl %x req %lld frame_skip_flag %d open_req_cnt:%u initial_sync_req [%lld,%lld] is_master:%d",
 		link->link_hdl, req_id, link->sync_link_sof_skip,
 		link->open_req_cnt, link->initial_sync_req,
 		sync_link->initial_sync_req, link->is_master);
@@ -1960,7 +1972,6 @@ static int __cam_req_mgr_process_req(struct cam_req_mgr_core_link *link,
 				&idx, reset_step + 1,
 				in_q->num_slots);
 			__cam_req_mgr_reset_req_slot(link, idx);
-			link->open_req_cnt--;
 		}
 	}
 end:
@@ -2358,7 +2369,8 @@ static void __cam_req_mgr_destroy_link_info(struct cam_req_mgr_core_link *link)
 
 	link->pd_mask = 0;
 	link->num_devs = 0;
-	link->max_delay = 0;
+	link->max_delay = CAM_PIPELINE_DELAY_0;
+	link->min_delay = CAM_PIPELINE_DELAY_MAX;
 }
 
 /**
@@ -2408,6 +2420,7 @@ static struct cam_req_mgr_core_link *__cam_req_mgr_reserve_link(
 	mutex_lock(&link->lock);
 	link->num_devs = 0;
 	link->max_delay = 0;
+	link->min_delay = CAM_PIPELINE_DELAY_MAX;
 	memset(in_q->slot, 0,
 		sizeof(struct cam_req_mgr_slot) * MAX_REQ_SLOTS);
 	link->req.in_q = in_q;
@@ -2675,6 +2688,9 @@ int cam_req_mgr_process_sched_req(void *priv, void *data)
 	}
 
 	link->open_req_cnt++;
+	CAM_DBG(CAM_REQ, "Open_req_cnt: %u after scheduling req: %d",
+		link->open_req_cnt,
+		sched_req->req_id);
 	__cam_req_mgr_inc_idx(&in_q->wr_idx, 1, in_q->num_slots);
 
 	if (slot->sync_mode == CAM_REQ_MGR_SYNC_MODE_SYNC) {
@@ -3715,8 +3731,10 @@ static int __cam_req_mgr_setup_link_info(struct cam_req_mgr_core_link *link,
 		/* Communicate with dev to establish the link */
 		dev->ops->link_setup(&link_data);
 
-		if (link->max_delay < dev->dev_info.p_delay)
+		if (dev->dev_info.p_delay > link->max_delay)
 			link->max_delay = dev->dev_info.p_delay;
+		if (dev->dev_info.p_delay < link->min_delay)
+			link->min_delay = dev->dev_info.p_delay;
 	}
 	link->num_devs = num_devices;
 

+ 4 - 2
drivers/cam_req_mgr/cam_req_mgr_core.h

@@ -177,7 +177,7 @@ struct cam_req_mgr_traverse {
 	struct cam_req_mgr_apply          *apply_data;
 	struct cam_req_mgr_req_queue      *in_q;
 	bool                               validate_only;
-	int32_t                            open_req_cnt;
+	uint32_t                           open_req_cnt;
 };
 
 /**
@@ -338,6 +338,7 @@ struct cam_req_mgr_connected_device {
  * @link_hdl             : Link identifier
  * @num_devs             : num of connected devices to this link
  * @max_delay            : Max of pipeline delay of all connected devs
+ * @min_delay            : Min of pipeline delay of all connected devs
  * @workq                : Pointer to handle workq related jobs
  * @pd_mask              : each set bit indicates the device with pd equal to
  *                          bit position is available.
@@ -389,6 +390,7 @@ struct cam_req_mgr_core_link {
 	int32_t                              link_hdl;
 	int32_t                              num_devs;
 	enum cam_pipeline_delay              max_delay;
+	enum cam_pipeline_delay              min_delay;
 	struct cam_req_mgr_core_workq       *workq;
 	int32_t                              pd_mask;
 	struct cam_req_mgr_connected_device *l_dev;
@@ -403,7 +405,7 @@ struct cam_req_mgr_core_link {
 			*sync_link[MAXIMUM_LINKS_PER_SESSION - 1];
 	int32_t                              num_sync_links;
 	bool                                 sync_link_sof_skip;
-	int32_t                              open_req_cnt;
+	uint32_t                             open_req_cnt;
 	uint32_t                             last_flush_id;
 	atomic_t                             is_used;
 	bool                                 is_master;