summaryrefslogtreecommitdiffstats
path: root/src/intel/perf/gen_perf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/intel/perf/gen_perf.c')
-rw-r--r--src/intel/perf/gen_perf.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/intel/perf/gen_perf.c b/src/intel/perf/gen_perf.c
index 26f6da88d90..76caefe6bd0 100644
--- a/src/intel/perf/gen_perf.c
+++ b/src/intel/perf/gen_perf.c
@@ -44,6 +44,8 @@
#define FILE_DEBUG_FLAG DEBUG_PERFMON
#define MI_RPC_BO_SIZE 4096
#define MI_FREQ_START_OFFSET_BYTES (3072)
+#define MI_RPC_BO_END_OFFSET_BYTES (MI_RPC_BO_SIZE / 2)
+#define MI_FREQ_END_OFFSET_BYTES (3076)
#define MAP_READ (1 << 0)
#define MAP_WRITE (1 << 1)
@@ -1283,3 +1285,55 @@ gen_perf_begin_query(struct gen_perf_context *perf_ctx,
return true;
}
+
+void
+gen_perf_end_query(struct gen_perf_context *perf_ctx,
+ struct gen_perf_query_object *query)
+{
+ struct gen_perf_config *perf_cfg = perf_ctx->perf;
+
+ /* Ensure that the work associated with the queried commands will have
+ * finished before taking our query end counter readings.
+ *
+ * For more details see comment in brw_begin_perf_query for
+ * corresponding flush.
+ */
+ perf_cfg->vtbl.emit_mi_flush(perf_ctx->ctx);
+
+ switch (query->queryinfo->kind) {
+ case GEN_PERF_QUERY_TYPE_OA:
+ case GEN_PERF_QUERY_TYPE_RAW:
+
+ /* NB: It's possible that the query will have already been marked
+ * as 'accumulated' if an error was seen while reading samples
+ * from perf. In this case we mustn't try and emit a closing
+ * MI_RPC command in case the OA unit has already been disabled
+ */
+ if (!query->oa.results_accumulated) {
+ /* Take an ending OA counter snapshot. */
+ perf_cfg->vtbl.capture_frequency_stat_register(perf_ctx->ctx, query->oa.bo,
+ MI_FREQ_END_OFFSET_BYTES);
+ perf_cfg->vtbl.emit_mi_report_perf_count(perf_ctx->ctx, query->oa.bo,
+ MI_RPC_BO_END_OFFSET_BYTES,
+ query->oa.begin_report_id + 1);
+ }
+
+ --perf_ctx->n_active_oa_queries;
+
+ /* NB: even though the query has now ended, it can't be accumulated
+ * until the end MI_REPORT_PERF_COUNT snapshot has been written
+ * to query->oa.bo
+ */
+ break;
+
+ case GEN_PERF_QUERY_TYPE_PIPELINE:
+ gen_perf_snapshot_statistics_registers(perf_ctx->ctx, perf_cfg, query,
+ STATS_BO_END_OFFSET_BYTES);
+ --perf_ctx->n_active_pipeline_stats_queries;
+ break;
+
+ default:
+ unreachable("Unknown query type");
+ break;
+ }
+}