diff options
author | Mark Janes <[email protected]> | 2019-06-26 12:12:20 -0700 |
---|---|---|
committer | Mark Janes <[email protected]> | 2019-08-07 21:33:55 -0700 |
commit | a330d759c5b6c1b207933c0037e9ac52fabebdc8 (patch) | |
tree | 8815ca74b1a2e6d30128e1bbae2c7c2fd13a78eb /src | |
parent | 4d0d4aa1b53eb63de1a54675ba50f74c59be620c (diff) |
intel/perf: move client reference counts into perf
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/intel/perf/gen_perf.c | 29 | ||||
-rw-r--r-- | src/intel/perf/gen_perf.h | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_performance_query.c | 41 |
3 files changed, 37 insertions, 36 deletions
diff --git a/src/intel/perf/gen_perf.c b/src/intel/perf/gen_perf.c index 33c86abec18..4adcd464f19 100644 --- a/src/intel/perf/gen_perf.c +++ b/src/intel/perf/gen_perf.c @@ -959,3 +959,32 @@ gen_perf_open(struct gen_perf_context *perf_ctx, return true; } + +bool +gen_perf_inc_n_users(struct gen_perf_context *perf_ctx) +{ + if (perf_ctx->n_oa_users == 0 && + gen_ioctl(perf_ctx->oa_stream_fd, I915_PERF_IOCTL_ENABLE, 0) < 0) + { + return false; + } + ++perf_ctx->n_oa_users; + + return true; +} + +void +gen_perf_dec_n_users(struct gen_perf_context *perf_ctx) +{ + /* Disabling the i915 perf stream will effectively disable the OA + * counters. Note it's important to be sure there are no outstanding + * MI_RPC commands at this point since they could stall the CS + * indefinitely once OACONTROL is disabled. + */ + --perf_ctx->n_oa_users; + if (perf_ctx->n_oa_users == 0 && + gen_ioctl(perf_ctx->oa_stream_fd, I915_PERF_IOCTL_DISABLE, 0) < 0) + { + DBG("WARNING: Error disabling gen perf stream: %m\n"); + } +} diff --git a/src/intel/perf/gen_perf.h b/src/intel/perf/gen_perf.h index 6aef2356015..fe6551da76c 100644 --- a/src/intel/perf/gen_perf.h +++ b/src/intel/perf/gen_perf.h @@ -597,4 +597,7 @@ bool gen_perf_open(struct gen_perf_context *perfquery, int drm_fd, uint32_t ctx_id); +bool gen_perf_inc_n_users(struct gen_perf_context *perfquery); +void gen_perf_dec_n_users(struct gen_perf_context *perfquery); + #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 b6ef66322a4..e6b8e0d5898 100644 --- a/src/mesa/drivers/dri/i965/brw_performance_query.c +++ b/src/mesa/drivers/dri/i965/brw_performance_query.c @@ -311,38 +311,6 @@ drop_from_unaccumulated_query_list(struct brw_context *brw, gen_perf_reap_old_sample_buffers(&brw->perf_ctx); } -static bool -inc_n_oa_users(struct brw_context *brw) -{ - struct gen_perf_context *perf_ctx = &brw->perf_ctx; - if (perf_ctx->n_oa_users == 0 && - drmIoctl(perf_ctx->oa_stream_fd, - I915_PERF_IOCTL_ENABLE, 0) < 0) - { - return false; - } - ++perf_ctx->n_oa_users; - - return true; -} - -static void -dec_n_oa_users(struct brw_context *brw) -{ - /* Disabling the i915 perf stream will effectively disable the OA - * counters. Note it's important to be sure there are no outstanding - * MI_RPC commands at this point since they could stall the CS - * indefinitely once OACONTROL is disabled. - */ - struct gen_perf_context *perf_ctx = &brw->perf_ctx; - --perf_ctx->n_oa_users; - if (perf_ctx->n_oa_users == 0 && - drmIoctl(perf_ctx->oa_stream_fd, I915_PERF_IOCTL_DISABLE, 0) < 0) - { - DBG("WARNING: Error disabling i915 perf stream: %m\n"); - } -} - /* In general if we see anything spurious while accumulating results, * we don't try and continue accumulating the current query, hoping * for the best, we scrap anything outstanding, and then hope for the @@ -358,7 +326,7 @@ discard_all_queries(struct brw_context *brw) obj->oa.results_accumulated = true; drop_from_unaccumulated_query_list(brw, perf_ctx->unaccumulated[0]); - dec_n_oa_users(brw); + gen_perf_dec_n_users(perf_ctx); } } @@ -503,6 +471,7 @@ accumulate_oa_reports(struct brw_context *brw, { const struct gen_device_info *devinfo = &brw->screen->devinfo; struct gen_perf_query_object *obj = brw_query->query; + struct gen_perf_context *perf_ctx = &brw->perf_ctx; uint32_t *start; uint32_t *last; uint32_t *end; @@ -642,7 +611,7 @@ end: obj->oa.results_accumulated = true; drop_from_unaccumulated_query_list(brw, obj); - dec_n_oa_users(brw); + gen_perf_dec_n_users(perf_ctx); return; @@ -829,7 +798,7 @@ brw_begin_perf_query(struct gl_context *ctx, perf_ctx->current_oa_format == query->oa_format); } - if (!inc_n_oa_users(brw)) { + if (!gen_perf_inc_n_users(perf_ctx)) { DBG("WARNING: Error enabling i915 perf stream: %m\n"); return false; } @@ -1294,7 +1263,7 @@ brw_delete_perf_query(struct gl_context *ctx, if (obj->oa.bo) { if (!obj->oa.results_accumulated) { drop_from_unaccumulated_query_list(brw, obj); - dec_n_oa_users(brw); + gen_perf_dec_n_users(perf_ctx); } perf_cfg->vtbl.bo_unreference(obj->oa.bo); |