summaryrefslogtreecommitdiffstats
path: root/src/intel/perf/gen_perf.c
diff options
context:
space:
mode:
authorMark Janes <[email protected]>2019-06-26 12:12:20 -0700
committerMark Janes <[email protected]>2019-08-07 21:33:55 -0700
commita330d759c5b6c1b207933c0037e9ac52fabebdc8 (patch)
tree8815ca74b1a2e6d30128e1bbae2c7c2fd13a78eb /src/intel/perf/gen_perf.c
parent4d0d4aa1b53eb63de1a54675ba50f74c59be620c (diff)
intel/perf: move client reference counts into perf
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/intel/perf/gen_perf.c')
-rw-r--r--src/intel/perf/gen_perf.c29
1 files changed, 29 insertions, 0 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");
+ }
+}