intel/perf: move open_perf into perf
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
79ded7cc8f
commit
4d0d4aa1b5
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 &&
|
||||
|
|
Loading…
Reference in New Issue