diff options
author | Mark Janes <[email protected]> | 2019-05-30 18:09:02 -0700 |
---|---|---|
committer | Mark Janes <[email protected]> | 2019-08-07 21:33:55 -0700 |
commit | fb622054f7065d0a92547f20dba404e3e5aec38d (patch) | |
tree | 2f4276899f0d4bdf877a6f89726097b50ed37ced /src/intel/perf/gen_perf.c | |
parent | b14e15e26a8749935a28a7988e6dcd52a9454dc5 (diff) |
intel/perf: move get_metric_id to perf
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/intel/perf/gen_perf.c')
-rw-r--r-- | src/intel/perf/gen_perf.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/intel/perf/gen_perf.c b/src/intel/perf/gen_perf.c index d28da495761..76fe725e3b1 100644 --- a/src/intel/perf/gen_perf.c +++ b/src/intel/perf/gen_perf.c @@ -790,3 +790,37 @@ gen_perf_query_register_mdapi_statistic_query(const struct gen_device_info *devi query->data_size = sizeof(uint64_t) * query->n_counters; } +uint64_t +gen_perf_query_get_metric_id(struct gen_perf_config *perf, + const struct gen_perf_query_info *query) +{ + /* These queries are know not to ever change, their config ID has been + * loaded upon the first query creation. No need to look them up again. + */ + if (query->kind == GEN_PERF_QUERY_TYPE_OA) + return query->oa_metrics_set_id; + + assert(query->kind == GEN_PERF_QUERY_TYPE_RAW); + + /* Raw queries can be reprogrammed up by an external application/library. + * When a raw query is used for the first time it's id is set to a value != + * 0. When it stops being used the id returns to 0. No need to reload the + * ID when it's already loaded. + */ + if (query->oa_metrics_set_id != 0) { + DBG("Raw query '%s' guid=%s using cached ID: %"PRIu64"\n", + query->name, query->guid, query->oa_metrics_set_id); + return query->oa_metrics_set_id; + } + + struct gen_perf_query_info *raw_query = (struct gen_perf_query_info *)query; + if (!gen_perf_load_metric_id(perf, query->guid, + &raw_query->oa_metrics_set_id)) { + DBG("Unable to read query guid=%s ID, falling back to test config\n", query->guid); + raw_query->oa_metrics_set_id = 1ULL; + } else { + DBG("Raw query '%s'guid=%s loaded ID: %"PRIu64"\n", + query->name, query->guid, query->oa_metrics_set_id); + } + return query->oa_metrics_set_id; +} |