Skip to content

Commit 7831e9a

Browse files
committed
drm/i915/perf: Allow dynamic reconfiguration of the OA stream
Introduce a new perf_ioctl command to change the OA configuration of the active stream. This allows the OA stream to be reconfigured between batch buffers, giving greater flexibility in sampling. We inject a request into the OA context to reconfigure the stream asynchronously on the GPU in between and ordered with execbuffer calls. Original patch for dynamic reconfiguration by Lionel Landwerlin. Link: https://gitlab.freedesktop.org/mesa/mesa/merge_requests/932 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20191014201404.22468-3-chris@chris-wilson.co.uk
1 parent 4f6ccc7 commit 7831e9a

2 files changed

Lines changed: 58 additions & 1 deletion

File tree

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

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2862,6 +2862,40 @@ static void i915_perf_disable_locked(struct i915_perf_stream *stream)
28622862
stream->ops->disable(stream);
28632863
}
28642864

2865+
static long i915_perf_config_locked(struct i915_perf_stream *stream,
2866+
unsigned long metrics_set)
2867+
{
2868+
struct i915_oa_config *config;
2869+
long ret = stream->oa_config->id;
2870+
2871+
config = i915_perf_get_oa_config(stream->perf, metrics_set);
2872+
if (!config)
2873+
return -EINVAL;
2874+
2875+
if (config != stream->oa_config) {
2876+
int err;
2877+
2878+
/*
2879+
* If OA is bound to a specific context, emit the
2880+
* reconfiguration inline from that context. The update
2881+
* will then be ordered with respect to submission on that
2882+
* context.
2883+
*
2884+
* When set globally, we use a low priority kernel context,
2885+
* so it will effectively take effect when idle.
2886+
*/
2887+
err = emit_oa_config(stream, oa_context(stream));
2888+
if (err == 0)
2889+
config = xchg(&stream->oa_config, config);
2890+
else
2891+
ret = err;
2892+
}
2893+
2894+
i915_oa_config_put(config);
2895+
2896+
return ret;
2897+
}
2898+
28652899
/**
28662900
* i915_perf_ioctl - support ioctl() usage with i915 perf stream FDs
28672901
* @stream: An i915 perf stream
@@ -2885,6 +2919,8 @@ static long i915_perf_ioctl_locked(struct i915_perf_stream *stream,
28852919
case I915_PERF_IOCTL_DISABLE:
28862920
i915_perf_disable_locked(stream);
28872921
return 0;
2922+
case I915_PERF_IOCTL_CONFIG:
2923+
return i915_perf_config_locked(stream, arg);
28882924
}
28892925

28902926
return -EINVAL;
@@ -4023,7 +4059,15 @@ void i915_perf_fini(struct drm_i915_private *i915)
40234059
*/
40244060
int i915_perf_ioctl_version(void)
40254061
{
4026-
return 1;
4062+
/*
4063+
* 1: Initial version
4064+
* I915_PERF_IOCTL_ENABLE
4065+
* I915_PERF_IOCTL_DISABLE
4066+
*
4067+
* 2: Added runtime modification of OA config.
4068+
* I915_PERF_IOCTL_CONFIG
4069+
*/
4070+
return 2;
40274071
}
40284072

40294073
#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)

‎include/uapi/drm/i915_drm.h‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,6 +1932,19 @@ struct drm_i915_perf_open_param {
19321932
*/
19331933
#define I915_PERF_IOCTL_DISABLE _IO('i', 0x1)
19341934

1935+
/**
1936+
* Change metrics_set captured by a stream.
1937+
*
1938+
* If the stream is bound to a specific context, the configuration change
1939+
* will performed inline with that context such that it takes effect before
1940+
* the next execbuf submission.
1941+
*
1942+
* Returns the previously bound metrics set id, or a negative error code.
1943+
*
1944+
* This ioctl is available in perf revision 2.
1945+
*/
1946+
#define I915_PERF_IOCTL_CONFIG _IO('i', 0x2)
1947+
19351948
/**
19361949
* Common to all i915 perf records
19371950
*/

0 commit comments

Comments
 (0)