Sfoglia il codice sorgente

msm: camera: icp: Compute and log FW avg response time per ctx

Compute and log average firmware response time per context to
measure firmware latency.

CRs-Fixed: 3223208
Change-Id: Iaf27a43259fc2a558fdd59165f8afdd4f8e5f6e7
Signed-off-by: Sokchetra Eung <[email protected]>
Sokchetra Eung 3 anni fa
parent
commit
0d74d403bc

+ 32 - 0
drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c

@@ -2297,6 +2297,26 @@ static void cam_icp_mgr_dump_active_req_info(void)
 		total_active_streams, total_active_requests);
 }
 
+static void cam_icp_mgr_compute_fw_avg_response_time(struct cam_icp_hw_ctx_data *ctx_data,
+	uint32_t request_idx)
+{
+	struct cam_icp_ctx_perf_stats *perf_stats;
+	uint64_t delta;
+
+	delta = ktime_ms_delta(ktime_get(),
+		ctx_data->hfi_frame_process.submit_timestamp[request_idx]);
+
+	perf_stats = &ctx_data->perf_stats;
+	perf_stats->total_resp_time += delta;
+	perf_stats->total_requests++;
+
+	CAM_DBG(CAM_PERF,
+		"Avg response time on ctx: %s, current_req: %llu total_processed_requests: %llu avg_time: %llums",
+		ctx_data->ctx_id_string,
+		ctx_data->hfi_frame_process.request_id[request_idx], perf_stats->total_requests,
+		(perf_stats->total_resp_time / perf_stats->total_requests));
+}
+
 static int cam_icp_mgr_handle_frame_process(uint32_t *msg_ptr, int flag)
 {
 	int i;
@@ -2351,6 +2371,8 @@ static int cam_icp_mgr_handle_frame_process(uint32_t *msg_ptr, int flag)
 	}
 	idx = i;
 
+	cam_icp_mgr_compute_fw_avg_response_time(ctx_data, idx);
+
 	if (flag == ICP_FRAME_PROCESS_FAILURE) {
 		if (ioconfig_ack->err_type == CAMERAICP_EABORTED) {
 			CAM_WARN(CAM_ICP,
@@ -3935,6 +3957,7 @@ static int cam_icp_mgr_destroy_handle(
 
 static int cam_icp_mgr_release_ctx(struct cam_icp_hw_mgr *hw_mgr, int ctx_id)
 {
+	struct cam_icp_ctx_perf_stats *perf_stats;
 	int i = 0;
 
 	if (ctx_id >= CAM_ICP_CTX_MAX) {
@@ -3943,6 +3966,12 @@ static int cam_icp_mgr_release_ctx(struct cam_icp_hw_mgr *hw_mgr, int ctx_id)
 	}
 
 	mutex_lock(&hw_mgr->ctx_data[ctx_id].ctx_mutex);
+	perf_stats = &hw_mgr->ctx_data[ctx_id].perf_stats;
+	CAM_DBG(CAM_PERF,
+		"Avg response time on ctx: %s, total_processed_requests: %llu avg_time: %llums",
+		hw_mgr->ctx_data[ctx_id].ctx_id_string, perf_stats->total_requests,
+		perf_stats->total_requests ?
+		(perf_stats->total_resp_time / perf_stats->total_requests) : 0);
 	memset(&(hw_mgr->ctx_data[ctx_id].err_inject_params), 0,
 		sizeof(struct cam_hw_err_param));
 	cam_icp_remove_ctx_bw(hw_mgr, &hw_mgr->ctx_data[ctx_id]);
@@ -6463,6 +6492,9 @@ static int cam_icp_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args)
 		goto ioconfig_failed;
 	}
 
+	ctx_data->perf_stats.total_resp_time = 0;
+	ctx_data->perf_stats.total_requests = 0;
+
 	ctx_data->hfi_frame_process.bits = bitmap_size * BITS_PER_BYTE;
 	hw_mgr->ctx_data[ctx_id].ctxt_event_cb = args->event_cb;
 	icp_dev_acquire_info->scratch_mem_size = ctx_data->scratch_mem_size;

+ 14 - 0
drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.h

@@ -188,6 +188,18 @@ struct cam_hangdump_mem_regions {
 	struct cam_cmd_mem_region_info mem_info_array[HANG_DUMP_REGIONS_MAX];
 };
 
+/**
+ * struct cam_icp_ctx_perf_stats -
+ *        ICP general Perf stats per ctx
+ *
+ * @total_resp_time: accumulative FW response time
+ * @total_requests : accumulative submitted requests
+ */
+struct cam_icp_ctx_perf_stats {
+	uint64_t total_resp_time;
+	uint64_t total_requests;
+};
+
 /**
  * struct hfi_frame_process_info
  * @hfi_frame_cmd: Frame process command info
@@ -271,6 +283,7 @@ struct cam_ctx_clk_info {
  * @icp_dev_io_info: io config resource
  * @last_flush_req: last flush req for this ctx
  * @err_inject_params: Error injection data for hw_mgr_ctx
+ * @perf_stats: performance statistics info
  * @unified_dev_type: Unified dev type which does not hold any priority info.
  *                    It's either IPE/BPS
  * @abort_timed_out: Indicates if abort timed out
@@ -298,6 +311,7 @@ struct cam_icp_hw_ctx_data {
 	uint64_t last_flush_req;
 	char ctx_id_string[128];
 	struct cam_hw_err_param err_inject_params;
+	struct cam_icp_ctx_perf_stats perf_stats;
 	uint32_t unified_dev_type;
 	bool abort_timed_out;
 };