intel/perf: move client reference counts into perf

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
Mark Janes
2019-06-26 12:12:20 -07:00
parent 4d0d4aa1b5
commit a330d759c5
3 changed files with 37 additions and 36 deletions

View File

@@ -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");
}
}