Skip to content

Commit 08f56f8

Browse files
icklejnikula
authored andcommitted
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: Lionel Landwerlin <[email protected]> Fixes: 15d0ace ("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: Chris Wilson <[email protected]> Cc: Lionel Landwerlin <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 4b4e973) Signed-off-by: Jani Nikula <[email protected]>
1 parent f4aaa44 commit 08f56f8

File tree

2 files changed

+43
-18
lines changed

2 files changed

+43
-18
lines changed

drivers/gpu/drm/i915/i915_perf.c

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,17 +1954,18 @@ get_oa_vma(struct i915_perf_stream *stream, struct i915_oa_config *oa_config)
19541954
return i915_vma_get(oa_bo->vma);
19551955
}
19561956

1957-
static int emit_oa_config(struct i915_perf_stream *stream,
1958-
struct i915_oa_config *oa_config,
1959-
struct intel_context *ce)
1957+
static struct i915_request *
1958+
emit_oa_config(struct i915_perf_stream *stream,
1959+
struct i915_oa_config *oa_config,
1960+
struct intel_context *ce)
19601961
{
19611962
struct i915_request *rq;
19621963
struct i915_vma *vma;
19631964
int err;
19641965

19651966
vma = get_oa_vma(stream, oa_config);
19661967
if (IS_ERR(vma))
1967-
return PTR_ERR(vma);
1968+
return ERR_CAST(vma);
19681969

19691970
err = i915_vma_pin(vma, 0, 0, PIN_GLOBAL | PIN_HIGH);
19701971
if (err)
@@ -1989,21 +1990,26 @@ static int emit_oa_config(struct i915_perf_stream *stream,
19891990
err = rq->engine->emit_bb_start(rq,
19901991
vma->node.start, 0,
19911992
I915_DISPATCH_SECURE);
1993+
if (err)
1994+
goto err_add_request;
1995+
1996+
i915_request_get(rq);
19921997
err_add_request:
19931998
i915_request_add(rq);
19941999
err_vma_unpin:
19952000
i915_vma_unpin(vma);
19962001
err_vma_put:
19972002
i915_vma_put(vma);
1998-
return err;
2003+
return err ? ERR_PTR(err) : rq;
19992004
}
20002005

20012006
static struct intel_context *oa_context(struct i915_perf_stream *stream)
20022007
{
20032008
return stream->pinned_ctx ?: stream->engine->kernel_context;
20042009
}
20052010

2006-
static int hsw_enable_metric_set(struct i915_perf_stream *stream)
2011+
static struct i915_request *
2012+
hsw_enable_metric_set(struct i915_perf_stream *stream)
20072013
{
20082014
struct intel_uncore *uncore = stream->uncore;
20092015

@@ -2406,7 +2412,8 @@ static int lrc_configure_all_contexts(struct i915_perf_stream *stream,
24062412
return oa_configure_all_contexts(stream, regs, ARRAY_SIZE(regs));
24072413
}
24082414

2409-
static int gen8_enable_metric_set(struct i915_perf_stream *stream)
2415+
static struct i915_request *
2416+
gen8_enable_metric_set(struct i915_perf_stream *stream)
24102417
{
24112418
struct intel_uncore *uncore = stream->uncore;
24122419
struct i915_oa_config *oa_config = stream->oa_config;
@@ -2448,7 +2455,7 @@ static int gen8_enable_metric_set(struct i915_perf_stream *stream)
24482455
*/
24492456
ret = lrc_configure_all_contexts(stream, oa_config);
24502457
if (ret)
2451-
return ret;
2458+
return ERR_PTR(ret);
24522459

24532460
return emit_oa_config(stream, oa_config, oa_context(stream));
24542461
}
@@ -2460,7 +2467,8 @@ static u32 oag_report_ctx_switches(const struct i915_perf_stream *stream)
24602467
0 : GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS);
24612468
}
24622469

2463-
static int gen12_enable_metric_set(struct i915_perf_stream *stream)
2470+
static struct i915_request *
2471+
gen12_enable_metric_set(struct i915_perf_stream *stream)
24642472
{
24652473
struct intel_uncore *uncore = stream->uncore;
24662474
struct i915_oa_config *oa_config = stream->oa_config;
@@ -2491,7 +2499,7 @@ static int gen12_enable_metric_set(struct i915_perf_stream *stream)
24912499
*/
24922500
ret = gen12_configure_all_contexts(stream, oa_config);
24932501
if (ret)
2494-
return ret;
2502+
return ERR_PTR(ret);
24952503

24962504
/*
24972505
* For Gen12, performance counters are context
@@ -2501,7 +2509,7 @@ static int gen12_enable_metric_set(struct i915_perf_stream *stream)
25012509
if (stream->ctx) {
25022510
ret = gen12_configure_oar_context(stream, true);
25032511
if (ret)
2504-
return ret;
2512+
return ERR_PTR(ret);
25052513
}
25062514

25072515
return emit_oa_config(stream, oa_config, oa_context(stream));
@@ -2696,6 +2704,20 @@ static const struct i915_perf_stream_ops i915_oa_stream_ops = {
26962704
.read = i915_oa_read,
26972705
};
26982706

2707+
static int i915_perf_stream_enable_sync(struct i915_perf_stream *stream)
2708+
{
2709+
struct i915_request *rq;
2710+
2711+
rq = stream->perf->ops.enable_metric_set(stream);
2712+
if (IS_ERR(rq))
2713+
return PTR_ERR(rq);
2714+
2715+
i915_request_wait(rq, 0, MAX_SCHEDULE_TIMEOUT);
2716+
i915_request_put(rq);
2717+
2718+
return 0;
2719+
}
2720+
26992721
/**
27002722
* i915_oa_stream_init - validate combined props for OA stream and init
27012723
* @stream: An i915 perf stream
@@ -2829,7 +2851,7 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream,
28292851
stream->ops = &i915_oa_stream_ops;
28302852
perf->exclusive_stream = stream;
28312853

2832-
ret = perf->ops.enable_metric_set(stream);
2854+
ret = i915_perf_stream_enable_sync(stream);
28332855
if (ret) {
28342856
DRM_DEBUG("Unable to enable metric set\n");
28352857
goto err_enable;
@@ -3147,7 +3169,7 @@ static long i915_perf_config_locked(struct i915_perf_stream *stream,
31473169
return -EINVAL;
31483170

31493171
if (config != stream->oa_config) {
3150-
int err;
3172+
struct i915_request *rq;
31513173

31523174
/*
31533175
* If OA is bound to a specific context, emit the
@@ -3158,11 +3180,13 @@ static long i915_perf_config_locked(struct i915_perf_stream *stream,
31583180
* When set globally, we use a low priority kernel context,
31593181
* so it will effectively take effect when idle.
31603182
*/
3161-
err = emit_oa_config(stream, config, oa_context(stream));
3162-
if (err == 0)
3183+
rq = emit_oa_config(stream, config, oa_context(stream));
3184+
if (!IS_ERR(rq)) {
31633185
config = xchg(&stream->oa_config, config);
3164-
else
3165-
ret = err;
3186+
i915_request_put(rq);
3187+
} else {
3188+
ret = PTR_ERR(rq);
3189+
}
31663190
}
31673191

31683192
i915_oa_config_put(config);

drivers/gpu/drm/i915/i915_perf_types.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ struct i915_oa_ops {
339339
* counter reports being sampled. May apply system constraints such as
340340
* disabling EU clock gating as required.
341341
*/
342-
int (*enable_metric_set)(struct i915_perf_stream *stream);
342+
struct i915_request *
343+
(*enable_metric_set)(struct i915_perf_stream *stream);
343344

344345
/**
345346
* @disable_metric_set: Remove system constraints associated with using

0 commit comments

Comments
 (0)