[PATCH 15/15] drm/i915/gem: CTX_TRACE

Chris Wilson chris at chris-wilson.co.uk
Mon Jan 18 23:01:33 UTC 2021


Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c | 23 +++++++++++++++++++++
 include/uapi/drm/i915_drm.h                 |  7 +++++++
 2 files changed, 30 insertions(+)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index e314605c82df..d5bb17d3fbb0 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -1961,6 +1961,25 @@ get_engines(struct i915_gem_context *ctx,
 	return err;
 }
 
+static int
+get_trace(struct i915_gem_context *ctx,
+	  struct drm_i915_gem_context_param *args)
+{
+	int fd;
+
+	if (args->ctx_id) /* single trace per-fd, let's not mix it up! */
+		return -EINVAL;
+
+	fd = anon_trace_getfd("i915-client", ctx->file_priv->client->trace);
+	if (fd < 0)
+		return fd;
+
+	args->size = 0;
+	args->value = fd;
+
+	return 0;
+}
+
 static int
 set_persistence(struct i915_gem_context *ctx,
 		const struct drm_i915_gem_context_param *args)
@@ -2541,6 +2560,10 @@ int i915_gem_context_getparam_ioctl(struct drm_device *dev, void *data,
 		ret = get_ringsize(ctx, args);
 		break;
 
+	case I915_CONTEXT_PARAM_TRACE:
+		ret = get_trace(ctx, args);
+		break;
+
 	case I915_CONTEXT_PARAM_BAN_PERIOD:
 	default:
 		ret = -EINVAL;
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index 1987e2ea79a3..d3339caed3ec 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -1694,6 +1694,13 @@ struct drm_i915_gem_context_param {
  * Default is 16 KiB.
  */
 #define I915_CONTEXT_PARAM_RINGSIZE	0xc
+
+/*
+ * I915_CONTEXT_PARAM_TRACE:
+ *
+ * Return an fd representing a pipe of all trace output from this file.
+ */
+#define I915_CONTEXT_PARAM_TRACE	0xd
 /* Must be kept compact -- no holes and well documented */
 
 	__u64 value;
-- 
2.20.1



More information about the Intel-gfx-trybot mailing list