From 4d0d4aa1b53eb63de1a54675ba50f74c59be620c Mon Sep 17 00:00:00 2001 From: Mark Janes Date: Wed, 26 Jun 2019 11:56:07 -0700 Subject: [PATCH] intel/perf: move open_perf into perf Reviewed-by: Kenneth Graunke --- src/intel/perf/gen_perf.c | 41 +++++++++++++++ src/intel/perf/gen_perf.h | 6 +++ .../drivers/dri/i965/brw_performance_query.c | 50 +------------------ 3 files changed, 49 insertions(+), 48 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 */ diff --git a/src/mesa/drivers/dri/i965/brw_performance_query.c b/src/mesa/drivers/dri/i965/brw_performance_query.c index f4e62de3b7d..b6ef66322a4 100644 --- a/src/mesa/drivers/dri/i965/brw_performance_query.c +++ b/src/mesa/drivers/dri/i965/brw_performance_query.c @@ -653,48 +653,6 @@ error: /******************************************************************************/ -static bool -open_i915_perf_oa_stream(struct brw_context *brw, - 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 = drmIoctl(drm_fd, DRM_IOCTL_I915_PERF_OPEN, ¶m); - if (fd == -1) { - DBG("Error opening i915 perf OA stream: %m\n"); - return false; - } - - struct gen_perf_context *perf_ctx = &brw->perf_ctx; - 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; -} - static void capture_frequency_stat_register(struct brw_context *brw, struct brw_bo *bo, @@ -863,12 +821,8 @@ brw_begin_perf_query(struct gl_context *ctx, DBG("OA sampling exponent: %i ~= %"PRIu64"ms\n", period_exponent, prev_sample_period / 1000000ul); - if (!open_i915_perf_oa_stream(brw, - metric_id, - query->oa_format, - period_exponent, - screen->fd, /* drm fd */ - brw->hw_ctx)) + if (!gen_perf_open(perf_ctx, metric_id, query->oa_format, + period_exponent, screen->fd, brw->hw_ctx)) return false; } else { assert(perf_ctx->current_oa_metrics_set_id == metric_id && -- 2.30.2