diff options
author | Mark Janes <mark.a.janes@intel.com> | 2019-06-26 11:56:07 -0700 |
---|---|---|
committer | Mark Janes <mark.a.janes@intel.com> | 2019-08-07 21:33:55 -0700 |
commit | 4d0d4aa1b53eb63de1a54675ba50f74c59be620c (patch) | |
tree | 3f88be3423761ec574657658e88c541696776516 /src/intel/perf | |
parent | 79ded7cc8f0b146bdf153f12093b6b6766fcf06b (diff) | |
download | mesa-4d0d4aa1b53eb63de1a54675ba50f74c59be620c.tar.gz |
intel/perf: move open_perf into perf
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/intel/perf')
-rw-r--r-- | src/intel/perf/gen_perf.c | 41 | ||||
-rw-r--r-- | src/intel/perf/gen_perf.h | 6 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/intel/perf/gen_perf.c b/src/intel/perf/gen_perf.c index 99f9cd7e097..33c86abec18 100644 --- a/src/intel/perf/gen_perf.c +++ b/src/intel/perf/gen_perf.c @@ -918,3 +918,44 @@ gen_perf_close(struct gen_perf_context *perfquery, raw_query->oa_metrics_set_id = 0; } } + +bool +gen_perf_open(struct gen_perf_context *perf_ctx, + int metrics_set_id, + int report_format, + int period_exponent, + int drm_fd, + uint32_t ctx_id) +{ + uint64_t properties[] = { + /* Single context sampling */ + DRM_I915_PERF_PROP_CTX_HANDLE, ctx_id, + + /* Include OA reports in samples */ + DRM_I915_PERF_PROP_SAMPLE_OA, true, + + /* OA unit configuration */ + DRM_I915_PERF_PROP_OA_METRICS_SET, metrics_set_id, + DRM_I915_PERF_PROP_OA_FORMAT, report_format, + DRM_I915_PERF_PROP_OA_EXPONENT, period_exponent, + }; + struct drm_i915_perf_open_param param = { + .flags = I915_PERF_FLAG_FD_CLOEXEC | + I915_PERF_FLAG_FD_NONBLOCK | + I915_PERF_FLAG_DISABLED, + .num_properties = ARRAY_SIZE(properties) / 2, + .properties_ptr = (uintptr_t) properties, + }; + int fd = gen_ioctl(drm_fd, DRM_IOCTL_I915_PERF_OPEN, ¶m); + if (fd == -1) { + DBG("Error opening gen perf OA stream: %m\n"); + return false; + } + + perf_ctx->oa_stream_fd = fd; + + perf_ctx->current_oa_metrics_set_id = metrics_set_id; + perf_ctx->current_oa_format = report_format; + + return true; +} diff --git a/src/intel/perf/gen_perf.h b/src/intel/perf/gen_perf.h index a693ec3800f..6aef2356015 100644 --- a/src/intel/perf/gen_perf.h +++ b/src/intel/perf/gen_perf.h @@ -590,5 +590,11 @@ void gen_perf_snapshot_statistics_registers(void *context, void gen_perf_close(struct gen_perf_context *perfquery, const struct gen_perf_query_info *query); +bool gen_perf_open(struct gen_perf_context *perfquery, + int metrics_set_id, + int report_format, + int period_exponent, + int drm_fd, + uint32_t ctx_id); #endif /* GEN_PERF_H */ |