[Intel-gfx] [PATCH 06/18] drm/i915: trace events for contexts

Ben Widawsky ben at bwidawsk.net
Sun Mar 18 21:39:46 CET 2012


Recommended by Daniel Vetter. The original code used DRM_DEBUG_DRIVER.
With this we track context creation, destruction, and switching.

Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_gem_context.c |    7 +++-
 drivers/gpu/drm/i915/i915_trace.h       |   59 +++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index cc508d5..f1559285 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -72,6 +72,8 @@ static void do_destroy(struct i915_hw_context *ctx)
 	else
 		BUG_ON(ctx != dev_priv->ring[RCS].default_context);
 
+	trace_i915_context_destroy(ctx);
+
 	drm_gem_object_unreference(&ctx->obj->base);
 	kfree(ctx);
 }
@@ -105,7 +107,7 @@ create_hw_context(struct drm_device *dev,
 
 	/* Default context will never have a file_priv */
 	if (file_priv == NULL)
-		return 0;
+		goto out;
 
 	(*ctx_out)->file_priv = file_priv;
 
@@ -127,7 +129,9 @@ again:
 	} else if (ret)
 		goto err_out;
 
+out:
 	(*ctx_out)->obj->context_id = (*ctx_out)->id;
+	trace_i915_context_create(*ctx_out);
 	return 0;
 
 err_out:
@@ -332,6 +336,7 @@ static int do_switch(struct drm_i915_gem_object *from_obj,
 
 	ring->last_context_obj = to->obj;
 
+	trace_i915_context_switch(from_obj, to);
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/i915/i915_trace.h b/drivers/gpu/drm/i915/i915_trace.h
index dac7bba..d72a6f1 100644
--- a/drivers/gpu/drm/i915/i915_trace.h
+++ b/drivers/gpu/drm/i915/i915_trace.h
@@ -410,6 +410,65 @@ TRACE_EVENT(i915_reg_rw,
 		(u32)(__entry->val >> 32))
 );
 
+/* Context tracking */
+TRACE_EVENT(i915_context_create,
+	    TP_PROTO(struct i915_hw_context *ctx),
+	    TP_ARGS(ctx),
+
+	    TP_STRUCT__entry(
+			     __field(struct i915_hw_context *, ctx)
+			     __field(u32, id)
+			     __field(struct drm_i915_gem_object *, obj)
+			     ),
+
+	    TP_fast_assign(
+			   __entry->ctx = ctx;
+			   __entry->id = ctx->id;
+			   __entry->obj = ctx->obj;
+			   ),
+
+	    TP_printk("ctx=%p, id=%u, obj=%p",
+		      __entry->ctx, __entry->id, __entry->obj)
+);
+
+TRACE_EVENT(i915_context_destroy,
+	    TP_PROTO(struct i915_hw_context *ctx),
+	    TP_ARGS(ctx),
+
+	    TP_STRUCT__entry(
+			     __field(struct i915_hw_context *, ctx)
+			     __field(u32, id)
+			     ),
+
+	    TP_fast_assign(
+			   __entry->ctx = ctx;
+			   __entry->id = ctx->id;
+			   ),
+
+	    TP_printk("ctx=%p, id=%u", __entry->ctx, __entry->id)
+);
+
+TRACE_EVENT(i915_context_switch,
+	    TP_PROTO(struct drm_i915_gem_object *from, struct i915_hw_context *to),
+	    TP_ARGS(from, to),
+
+	    TP_STRUCT__entry(
+			     __field(struct drm_i915_gem_object *, fobj)
+			     __field(struct drm_i915_gem_object *, tobj)
+			     __field(u32, idf)
+			     __field(u32, idt)
+			    ),
+
+	    TP_fast_assign(
+			   __entry->fobj = from;
+			   __entry->idf = (from == NULL) ? -1 : to->obj->context_id;
+			   __entry->tobj = to->obj;
+			   __entry->idt = to->id;
+			   ),
+
+	    TP_printk("context switch from %u (%p) to %u (%p)",
+		      __entry->idf, __entry->fobj, __entry->idt, __entry->tobj)
+);
 #endif /* _I915_TRACE_H_ */
 
 /* This part must be outside protection */
-- 
1.7.9.4




More information about the Intel-gfx mailing list