Commit 4b4e973d authored by Chris Wilson's avatar Chris Wilson

drm/i915/perf: Reintroduce wait on OA configuration completion

We still need to wait for the initial OA configuration to happen
before we enable OA report writes to the OA buffer.
Reported-by: default avatarLionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 15d0ace1 ("drm/i915/perf: execute OA configuration from command stream")
Closes: https://gitlab.freedesktop.org/drm/intel/issues/1356
Testcase: igt/perf/stream-open-close
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: default avatarLionel Landwerlin <lionel.g.landwerlin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200302085812.4172450-7-chris@chris-wilson.co.uk
parent f5e5a330
...@@ -1972,7 +1972,8 @@ get_oa_vma(struct i915_perf_stream *stream, struct i915_oa_config *oa_config) ...@@ -1972,7 +1972,8 @@ get_oa_vma(struct i915_perf_stream *stream, struct i915_oa_config *oa_config)
return i915_vma_get(oa_bo->vma); return i915_vma_get(oa_bo->vma);
} }
static int emit_oa_config(struct i915_perf_stream *stream, static struct i915_request *
emit_oa_config(struct i915_perf_stream *stream,
struct i915_oa_config *oa_config, struct i915_oa_config *oa_config,
struct intel_context *ce) struct intel_context *ce)
{ {
...@@ -1982,7 +1983,7 @@ static int emit_oa_config(struct i915_perf_stream *stream, ...@@ -1982,7 +1983,7 @@ static int emit_oa_config(struct i915_perf_stream *stream,
vma = get_oa_vma(stream, oa_config); vma = get_oa_vma(stream, oa_config);
if (IS_ERR(vma)) if (IS_ERR(vma))
return PTR_ERR(vma); return ERR_CAST(vma);
err = i915_vma_pin(vma, 0, 0, PIN_GLOBAL | PIN_HIGH); err = i915_vma_pin(vma, 0, 0, PIN_GLOBAL | PIN_HIGH);
if (err) if (err)
...@@ -2007,13 +2008,17 @@ static int emit_oa_config(struct i915_perf_stream *stream, ...@@ -2007,13 +2008,17 @@ static int emit_oa_config(struct i915_perf_stream *stream,
err = rq->engine->emit_bb_start(rq, err = rq->engine->emit_bb_start(rq,
vma->node.start, 0, vma->node.start, 0,
I915_DISPATCH_SECURE); I915_DISPATCH_SECURE);
if (err)
goto err_add_request;
i915_request_get(rq);
err_add_request: err_add_request:
i915_request_add(rq); i915_request_add(rq);
err_vma_unpin: err_vma_unpin:
i915_vma_unpin(vma); i915_vma_unpin(vma);
err_vma_put: err_vma_put:
i915_vma_put(vma); i915_vma_put(vma);
return err; return err ? ERR_PTR(err) : rq;
} }
static struct intel_context *oa_context(struct i915_perf_stream *stream) static struct intel_context *oa_context(struct i915_perf_stream *stream)
...@@ -2021,7 +2026,8 @@ static struct intel_context *oa_context(struct i915_perf_stream *stream) ...@@ -2021,7 +2026,8 @@ static struct intel_context *oa_context(struct i915_perf_stream *stream)
return stream->pinned_ctx ?: stream->engine->kernel_context; return stream->pinned_ctx ?: stream->engine->kernel_context;
} }
static int hsw_enable_metric_set(struct i915_perf_stream *stream) static struct i915_request *
hsw_enable_metric_set(struct i915_perf_stream *stream)
{ {
struct intel_uncore *uncore = stream->uncore; struct intel_uncore *uncore = stream->uncore;
...@@ -2426,7 +2432,8 @@ static int lrc_configure_all_contexts(struct i915_perf_stream *stream, ...@@ -2426,7 +2432,8 @@ static int lrc_configure_all_contexts(struct i915_perf_stream *stream,
return oa_configure_all_contexts(stream, regs, ARRAY_SIZE(regs)); return oa_configure_all_contexts(stream, regs, ARRAY_SIZE(regs));
} }
static int gen8_enable_metric_set(struct i915_perf_stream *stream) static struct i915_request *
gen8_enable_metric_set(struct i915_perf_stream *stream)
{ {
struct intel_uncore *uncore = stream->uncore; struct intel_uncore *uncore = stream->uncore;
struct i915_oa_config *oa_config = stream->oa_config; struct i915_oa_config *oa_config = stream->oa_config;
...@@ -2468,7 +2475,7 @@ static int gen8_enable_metric_set(struct i915_perf_stream *stream) ...@@ -2468,7 +2475,7 @@ static int gen8_enable_metric_set(struct i915_perf_stream *stream)
*/ */
ret = lrc_configure_all_contexts(stream, oa_config); ret = lrc_configure_all_contexts(stream, oa_config);
if (ret) if (ret)
return ret; return ERR_PTR(ret);
return emit_oa_config(stream, oa_config, oa_context(stream)); return emit_oa_config(stream, oa_config, oa_context(stream));
} }
...@@ -2480,7 +2487,8 @@ static u32 oag_report_ctx_switches(const struct i915_perf_stream *stream) ...@@ -2480,7 +2487,8 @@ static u32 oag_report_ctx_switches(const struct i915_perf_stream *stream)
0 : GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS); 0 : GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS);
} }
static int gen12_enable_metric_set(struct i915_perf_stream *stream) static struct i915_request *
gen12_enable_metric_set(struct i915_perf_stream *stream)
{ {
struct intel_uncore *uncore = stream->uncore; struct intel_uncore *uncore = stream->uncore;
struct i915_oa_config *oa_config = stream->oa_config; struct i915_oa_config *oa_config = stream->oa_config;
...@@ -2511,7 +2519,7 @@ static int gen12_enable_metric_set(struct i915_perf_stream *stream) ...@@ -2511,7 +2519,7 @@ static int gen12_enable_metric_set(struct i915_perf_stream *stream)
*/ */
ret = gen12_configure_all_contexts(stream, oa_config); ret = gen12_configure_all_contexts(stream, oa_config);
if (ret) if (ret)
return ret; return ERR_PTR(ret);
/* /*
* For Gen12, performance counters are context * For Gen12, performance counters are context
...@@ -2521,7 +2529,7 @@ static int gen12_enable_metric_set(struct i915_perf_stream *stream) ...@@ -2521,7 +2529,7 @@ static int gen12_enable_metric_set(struct i915_perf_stream *stream)
if (stream->ctx) { if (stream->ctx) {
ret = gen12_configure_oar_context(stream, true); ret = gen12_configure_oar_context(stream, true);
if (ret) if (ret)
return ret; return ERR_PTR(ret);
} }
return emit_oa_config(stream, oa_config, oa_context(stream)); return emit_oa_config(stream, oa_config, oa_context(stream));
...@@ -2719,6 +2727,20 @@ static const struct i915_perf_stream_ops i915_oa_stream_ops = { ...@@ -2719,6 +2727,20 @@ static const struct i915_perf_stream_ops i915_oa_stream_ops = {
.read = i915_oa_read, .read = i915_oa_read,
}; };
static int i915_perf_stream_enable_sync(struct i915_perf_stream *stream)
{
struct i915_request *rq;
rq = stream->perf->ops.enable_metric_set(stream);
if (IS_ERR(rq))
return PTR_ERR(rq);
i915_request_wait(rq, 0, MAX_SCHEDULE_TIMEOUT);
i915_request_put(rq);
return 0;
}
/** /**
* i915_oa_stream_init - validate combined props for OA stream and init * i915_oa_stream_init - validate combined props for OA stream and init
* @stream: An i915 perf stream * @stream: An i915 perf stream
...@@ -2853,7 +2875,7 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream, ...@@ -2853,7 +2875,7 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream,
stream->ops = &i915_oa_stream_ops; stream->ops = &i915_oa_stream_ops;
WRITE_ONCE(perf->exclusive_stream, stream); WRITE_ONCE(perf->exclusive_stream, stream);
ret = perf->ops.enable_metric_set(stream); ret = i915_perf_stream_enable_sync(stream);
if (ret) { if (ret) {
DRM_DEBUG("Unable to enable metric set\n"); DRM_DEBUG("Unable to enable metric set\n");
goto err_enable; goto err_enable;
...@@ -3170,7 +3192,7 @@ static long i915_perf_config_locked(struct i915_perf_stream *stream, ...@@ -3170,7 +3192,7 @@ static long i915_perf_config_locked(struct i915_perf_stream *stream,
return -EINVAL; return -EINVAL;
if (config != stream->oa_config) { if (config != stream->oa_config) {
int err; struct i915_request *rq;
/* /*
* If OA is bound to a specific context, emit the * If OA is bound to a specific context, emit the
...@@ -3181,11 +3203,13 @@ static long i915_perf_config_locked(struct i915_perf_stream *stream, ...@@ -3181,11 +3203,13 @@ static long i915_perf_config_locked(struct i915_perf_stream *stream,
* When set globally, we use a low priority kernel context, * When set globally, we use a low priority kernel context,
* so it will effectively take effect when idle. * so it will effectively take effect when idle.
*/ */
err = emit_oa_config(stream, config, oa_context(stream)); rq = emit_oa_config(stream, config, oa_context(stream));
if (err == 0) if (!IS_ERR(rq)) {
config = xchg(&stream->oa_config, config); config = xchg(&stream->oa_config, config);
else i915_request_put(rq);
ret = err; } else {
ret = PTR_ERR(rq);
}
} }
i915_oa_config_put(config); i915_oa_config_put(config);
......
...@@ -339,7 +339,8 @@ struct i915_oa_ops { ...@@ -339,7 +339,8 @@ struct i915_oa_ops {
* counter reports being sampled. May apply system constraints such as * counter reports being sampled. May apply system constraints such as
* disabling EU clock gating as required. * disabling EU clock gating as required.
*/ */
int (*enable_metric_set)(struct i915_perf_stream *stream); struct i915_request *
(*enable_metric_set)(struct i915_perf_stream *stream);
/** /**
* @disable_metric_set: Remove system constraints associated with using * @disable_metric_set: Remove system constraints associated with using
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment