diff --git a/src/intel/perf/gen_perf.c b/src/intel/perf/gen_perf.c index ba1b4f8b127..d9f20501512 100644 --- a/src/intel/perf/gen_perf.c +++ b/src/intel/perf/gen_perf.c @@ -770,6 +770,19 @@ load_oa_metrics(struct gen_perf_config *perf, int fd, /* sort counters in each individual group created by this function by name */ for (int i = existing_queries; i < perf->n_queries; ++i) sort_query(&perf->queries[i]); + + /* Select a fallback OA metric. Look for the TestOa metric or use the last + * one if no present (on HSW). + */ + for (int i = existing_queries; i < perf->n_queries; i++) { + if (perf->queries[i].symbol_name && + strcmp(perf->queries[i].symbol_name, "TestOa") == 0) { + perf->fallback_raw_oa_metric = perf->queries[i].oa_metrics_set_id; + break; + } + } + if (perf->fallback_raw_oa_metric == 0) + perf->fallback_raw_oa_metric = perf->queries[perf->n_queries - 1].oa_metrics_set_id; } struct gen_perf_registers * diff --git a/src/intel/perf/gen_perf.h b/src/intel/perf/gen_perf.h index 073236c4317..790719ccbad 100644 --- a/src/intel/perf/gen_perf.h +++ b/src/intel/perf/gen_perf.h @@ -283,6 +283,11 @@ struct gen_perf_config { */ struct hash_table *oa_metrics_table; + /* When MDAPI hasn't configured the metric we need to use by the time the + * query begins, this OA metric is used as a fallback. + */ + uint64_t fallback_raw_oa_metric; + /* Whether we have support for this platform. If true && n_queries == 0, * this means we will not be able to use i915-perf because of it is in * paranoid mode. diff --git a/src/intel/perf/gen_perf_query.c b/src/intel/perf/gen_perf_query.c index 7bd8e0277d2..593ab5c473b 100644 --- a/src/intel/perf/gen_perf_query.c +++ b/src/intel/perf/gen_perf_query.c @@ -423,7 +423,7 @@ get_metric_id(struct gen_perf_config *perf, 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; + raw_query->oa_metrics_set_id = perf->fallback_raw_oa_metric; } else { DBG("Raw query '%s'guid=%s loaded ID: %"PRIu64"\n", query->name, query->guid, query->oa_metrics_set_id);