@@ -1954,17 +1954,18 @@ get_oa_vma(struct i915_perf_stream *stream, struct i915_oa_config *oa_config)
1954
1954
return i915_vma_get (oa_bo -> vma );
1955
1955
}
1956
1956
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 )
1960
1961
{
1961
1962
struct i915_request * rq ;
1962
1963
struct i915_vma * vma ;
1963
1964
int err ;
1964
1965
1965
1966
vma = get_oa_vma (stream , oa_config );
1966
1967
if (IS_ERR (vma ))
1967
- return PTR_ERR (vma );
1968
+ return ERR_CAST (vma );
1968
1969
1969
1970
err = i915_vma_pin (vma , 0 , 0 , PIN_GLOBAL | PIN_HIGH );
1970
1971
if (err )
@@ -1989,21 +1990,26 @@ static int emit_oa_config(struct i915_perf_stream *stream,
1989
1990
err = rq -> engine -> emit_bb_start (rq ,
1990
1991
vma -> node .start , 0 ,
1991
1992
I915_DISPATCH_SECURE );
1993
+ if (err )
1994
+ goto err_add_request ;
1995
+
1996
+ i915_request_get (rq );
1992
1997
err_add_request :
1993
1998
i915_request_add (rq );
1994
1999
err_vma_unpin :
1995
2000
i915_vma_unpin (vma );
1996
2001
err_vma_put :
1997
2002
i915_vma_put (vma );
1998
- return err ;
2003
+ return err ? ERR_PTR ( err ) : rq ;
1999
2004
}
2000
2005
2001
2006
static struct intel_context * oa_context (struct i915_perf_stream * stream )
2002
2007
{
2003
2008
return stream -> pinned_ctx ?: stream -> engine -> kernel_context ;
2004
2009
}
2005
2010
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 )
2007
2013
{
2008
2014
struct intel_uncore * uncore = stream -> uncore ;
2009
2015
@@ -2406,7 +2412,8 @@ static int lrc_configure_all_contexts(struct i915_perf_stream *stream,
2406
2412
return oa_configure_all_contexts (stream , regs , ARRAY_SIZE (regs ));
2407
2413
}
2408
2414
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 )
2410
2417
{
2411
2418
struct intel_uncore * uncore = stream -> uncore ;
2412
2419
struct i915_oa_config * oa_config = stream -> oa_config ;
@@ -2448,7 +2455,7 @@ static int gen8_enable_metric_set(struct i915_perf_stream *stream)
2448
2455
*/
2449
2456
ret = lrc_configure_all_contexts (stream , oa_config );
2450
2457
if (ret )
2451
- return ret ;
2458
+ return ERR_PTR ( ret ) ;
2452
2459
2453
2460
return emit_oa_config (stream , oa_config , oa_context (stream ));
2454
2461
}
@@ -2460,7 +2467,8 @@ static u32 oag_report_ctx_switches(const struct i915_perf_stream *stream)
2460
2467
0 : GEN12_OAG_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS );
2461
2468
}
2462
2469
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 )
2464
2472
{
2465
2473
struct intel_uncore * uncore = stream -> uncore ;
2466
2474
struct i915_oa_config * oa_config = stream -> oa_config ;
@@ -2491,7 +2499,7 @@ static int gen12_enable_metric_set(struct i915_perf_stream *stream)
2491
2499
*/
2492
2500
ret = gen12_configure_all_contexts (stream , oa_config );
2493
2501
if (ret )
2494
- return ret ;
2502
+ return ERR_PTR ( ret ) ;
2495
2503
2496
2504
/*
2497
2505
* For Gen12, performance counters are context
@@ -2501,7 +2509,7 @@ static int gen12_enable_metric_set(struct i915_perf_stream *stream)
2501
2509
if (stream -> ctx ) {
2502
2510
ret = gen12_configure_oar_context (stream , true);
2503
2511
if (ret )
2504
- return ret ;
2512
+ return ERR_PTR ( ret ) ;
2505
2513
}
2506
2514
2507
2515
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 = {
2696
2704
.read = i915_oa_read ,
2697
2705
};
2698
2706
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
+
2699
2721
/**
2700
2722
* i915_oa_stream_init - validate combined props for OA stream and init
2701
2723
* @stream: An i915 perf stream
@@ -2829,7 +2851,7 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream,
2829
2851
stream -> ops = & i915_oa_stream_ops ;
2830
2852
perf -> exclusive_stream = stream ;
2831
2853
2832
- ret = perf -> ops . enable_metric_set (stream );
2854
+ ret = i915_perf_stream_enable_sync (stream );
2833
2855
if (ret ) {
2834
2856
DRM_DEBUG ("Unable to enable metric set\n" );
2835
2857
goto err_enable ;
@@ -3147,7 +3169,7 @@ static long i915_perf_config_locked(struct i915_perf_stream *stream,
3147
3169
return - EINVAL ;
3148
3170
3149
3171
if (config != stream -> oa_config ) {
3150
- int err ;
3172
+ struct i915_request * rq ;
3151
3173
3152
3174
/*
3153
3175
* 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,
3158
3180
* When set globally, we use a low priority kernel context,
3159
3181
* so it will effectively take effect when idle.
3160
3182
*/
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 )) {
3163
3185
config = xchg (& stream -> oa_config , config );
3164
- else
3165
- ret = err ;
3186
+ i915_request_put (rq );
3187
+ } else {
3188
+ ret = PTR_ERR (rq );
3189
+ }
3166
3190
}
3167
3191
3168
3192
i915_oa_config_put (config );
0 commit comments