Skip to content

Commit 4ef10fe

Browse files
drm/i915/perf: add new open param to configure polling of OA buffer
This new parameter let's the application choose how often the OA buffer should be checked on the CPU side for data availability. Longer polling period tend to reduce CPU overhead if the application does not care about somewhat real time data collection. v2: Allow disabling polling completely with 0 value (Lionel) v3: Version the new parameter (Joonas) v4: Rebase (Umesh) v5: Make poll delay value of 0 invalid (Umesh) v6: - Describe poll_oa_period (Ashutosh) - Fix comment for new poll parameter (Lionel) - Drop open_flags in read_properties_unlocked (Lionel) - Rename uapi parameter (Ashutosh) v7: Reword the comment in uapi (Ashutosh) Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com> Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200324185457.14635-4-umesh.nerlige.ramappa@intel.com
1 parent c51dbc6 commit 4ef10fe

3 files changed

Lines changed: 44 additions & 7 deletions

File tree

‎drivers/gpu/drm/i915/i915_perf.c‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,11 @@
248248
#define OA_TAIL_MARGIN_NSEC 100000ULL
249249
#define INVALID_TAIL_PTR 0xffffffff
250250

251-
/* frequency for checking whether the OA unit has written new reports to the
252-
* circular OA buffer...
251+
/* The default frequency for checking whether the OA unit has written new
252+
* reports to the circular OA buffer...
253253
*/
254-
#define POLL_FREQUENCY 200
255-
#define POLL_PERIOD (NSEC_PER_SEC / POLL_FREQUENCY)
254+
#define DEFAULT_POLL_FREQUENCY_HZ 200
255+
#define DEFAULT_POLL_PERIOD_NS (NSEC_PER_SEC / DEFAULT_POLL_FREQUENCY_HZ)
256256

257257
/* for sysctl proc_dointvec_minmax of dev.i915.perf_stream_paranoid */
258258
static u32 i915_perf_stream_paranoid = true;
@@ -339,6 +339,8 @@ static const struct i915_oa_format gen12_oa_formats[I915_OA_FORMAT_MAX] = {
339339
* @sseu: internal SSEU configuration computed either from the userspace
340340
* specified configuration in the opening parameters or a default value
341341
* (see get_default_sseu_config())
342+
* @poll_oa_period: The period in nanoseconds at which the CPU will check for OA
343+
* data availability
342344
*
343345
* As read_properties_unlocked() enumerates and validates the properties given
344346
* to open a stream of metrics the configuration is built up in the structure
@@ -361,6 +363,8 @@ struct perf_open_properties {
361363

362364
bool has_sseu;
363365
struct intel_sseu sseu;
366+
367+
u64 poll_oa_period;
364368
};
365369

366370
struct i915_oa_config_bo {
@@ -2600,7 +2604,7 @@ static void i915_oa_stream_enable(struct i915_perf_stream *stream)
26002604

26012605
if (stream->periodic)
26022606
hrtimer_start(&stream->poll_check_timer,
2603-
ns_to_ktime(POLL_PERIOD),
2607+
ns_to_ktime(stream->poll_oa_period),
26042608
HRTIMER_MODE_REL_PINNED);
26052609
}
26062610

@@ -3035,7 +3039,8 @@ static enum hrtimer_restart oa_poll_check_timer_cb(struct hrtimer *hrtimer)
30353039
wake_up(&stream->poll_wq);
30363040
}
30373041

3038-
hrtimer_forward_now(hrtimer, ns_to_ktime(POLL_PERIOD));
3042+
hrtimer_forward_now(hrtimer,
3043+
ns_to_ktime(stream->poll_oa_period));
30393044

30403045
return HRTIMER_RESTART;
30413046
}
@@ -3424,6 +3429,7 @@ i915_perf_open_ioctl_locked(struct i915_perf *perf,
34243429

34253430
stream->perf = perf;
34263431
stream->ctx = specific_ctx;
3432+
stream->poll_oa_period = props->poll_oa_period;
34273433

34283434
ret = i915_oa_stream_init(stream, param, props);
34293435
if (ret)
@@ -3502,6 +3508,7 @@ static int read_properties_unlocked(struct i915_perf *perf,
35023508
int ret;
35033509

35043510
memset(props, 0, sizeof(struct perf_open_properties));
3511+
props->poll_oa_period = DEFAULT_POLL_PERIOD_NS;
35053512

35063513
if (!n_props) {
35073514
DRM_DEBUG("No i915 perf properties given\n");
@@ -3634,6 +3641,14 @@ static int read_properties_unlocked(struct i915_perf *perf,
36343641
props->has_sseu = true;
36353642
break;
36363643
}
3644+
case DRM_I915_PERF_PROP_POLL_OA_PERIOD:
3645+
if (value < 100000 /* 100us */) {
3646+
DRM_DEBUG("OA availability timer too small (%lluns < 100us)\n",
3647+
value);
3648+
return -EINVAL;
3649+
}
3650+
props->poll_oa_period = value;
3651+
break;
36373652
case DRM_I915_PERF_PROP_MAX:
36383653
MISSING_CASE(id);
36393654
return -EINVAL;
@@ -4416,8 +4431,11 @@ int i915_perf_ioctl_version(void)
44164431
* 4: Add DRM_I915_PERF_PROP_ALLOWED_SSEU to limit what contexts can
44174432
* be run for the duration of the performance recording based on
44184433
* their SSEU configuration.
4434+
*
4435+
* 5: Add DRM_I915_PERF_PROP_POLL_OA_PERIOD parameter that controls the
4436+
* interval for the hrtimer used to check for OA data.
44194437
*/
4420-
return 4;
4438+
return 5;
44214439
}
44224440

44234441
#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)

‎drivers/gpu/drm/i915/i915_perf_types.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,12 @@ struct i915_perf_stream {
304304
* reprogrammed.
305305
*/
306306
struct i915_vma *noa_wait;
307+
308+
/**
309+
* @poll_oa_period: The period in nanoseconds at which the OA
310+
* buffer should be checked for available data.
311+
*/
312+
u64 poll_oa_period;
307313
};
308314

309315
/**

‎include/uapi/drm/i915_drm.h‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,6 +1980,19 @@ enum drm_i915_perf_property_id {
19801980
*/
19811981
DRM_I915_PERF_PROP_GLOBAL_SSEU,
19821982

1983+
/**
1984+
* This optional parameter specifies the timer interval in nanoseconds
1985+
* at which the i915 driver will check the OA buffer for available data.
1986+
* Minimum allowed value is 100 microseconds. A default value is used by
1987+
* the driver if this parameter is not specified. Note that larger timer
1988+
* values will reduce cpu consumption during OA perf captures. However,
1989+
* excessively large values would potentially result in OA buffer
1990+
* overwrites as captures reach end of the OA buffer.
1991+
*
1992+
* This property is available in perf revision 5.
1993+
*/
1994+
DRM_I915_PERF_PROP_POLL_OA_PERIOD,
1995+
19831996
DRM_I915_PERF_PROP_MAX /* non-ABI */
19841997
};
19851998

0 commit comments

Comments
 (0)