All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Widawsky <ben@bwidawsk.net>
To: intel-gfx@lists.freedesktop.org
Cc: Ben Widawsky <ben@bwidawsk.net>
Subject: [PATCH 06/18] drm/i915: trace events for contexts
Date: Sun, 18 Mar 2012 13:39:46 -0700	[thread overview]
Message-ID: <1332103198-25852-7-git-send-email-ben@bwidawsk.net> (raw)
In-Reply-To: <1332103198-25852-1-git-send-email-ben@bwidawsk.net>

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@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

  parent reply	other threads:[~2012-03-18 20:41 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-18 20:39 [PATCH 00/18] i915 HW Context Support Ben Widawsky
2012-03-18 20:39 ` [PATCH 01/18] drm/i915: CXT_SIZE register offsets added Ben Widawsky
2012-03-18 20:39 ` [PATCH 02/18] drm/i915: preliminary context support Ben Widawsky
2012-03-28 22:43   ` Daniel Vetter
2012-03-28 22:59     ` Ben Widawsky
2012-03-29  8:43       ` Daniel Vetter
2012-03-18 20:39 ` [PATCH 03/18] drm/i915: context basic create & destroy Ben Widawsky
2012-03-18 20:39 ` [PATCH 04/18] drm/i915: add context information to objects Ben Widawsky
2012-03-28 22:36   ` Daniel Vetter
2012-03-29  0:20     ` Ben Widawsky
2012-03-29  8:47       ` Daniel Vetter
2012-03-29 15:57         ` Ben Widawsky
2012-03-18 20:39 ` [PATCH 05/18] drm/i915: context switch implementation Ben Widawsky
2012-03-29 18:24   ` Daniel Vetter
2012-03-29 18:43     ` Ben Widawsky
2012-03-29 18:49       ` Daniel Vetter
2012-03-30 18:11         ` Ben Widawsky
2012-03-29 18:47   ` Daniel Vetter
2012-03-18 20:39 ` Ben Widawsky [this message]
2012-03-18 20:39 ` [PATCH 07/18] drm/i915: Ivybridge MI_ARB_ON_OFF context w/a Ben Widawsky
2012-03-18 20:39 ` [PATCH 08/18] drm/i915: PIPE_CONTROL_TLB_INVALIDATE Ben Widawsky
2012-03-18 20:39 ` [PATCH 09/18] drm/i915: possibly invalidate TLB before context switch Ben Widawsky
2012-03-29 19:25   ` Daniel Vetter
2012-03-30 18:39     ` Ben Widawsky
2012-03-30 19:01       ` Daniel Vetter
2012-03-18 20:39 ` [PATCH 10/18] drm/i915: use the default context Ben Widawsky
2012-03-18 20:39 ` [PATCH 11/18] drm/i915: switch to default context on idle Ben Widawsky
2012-03-29 19:29   ` Daniel Vetter
2012-03-29 20:28     ` Chris Wilson
2012-03-30 21:17     ` Ben Widawsky
2012-03-30 21:30       ` Daniel Vetter
2012-03-18 20:39 ` [PATCH 12/18] drm/i915: try to reset the gpu before unload Ben Widawsky
2012-03-29 19:31   ` Daniel Vetter
2012-03-30 18:50     ` Ben Widawsky
2012-03-30 19:05       ` Daniel Vetter
2012-03-30 16:54   ` Jesse Barnes
2012-03-30 17:30     ` Daniel Vetter
2012-03-18 20:39 ` [PATCH 13/18] drm/i915/context: create & destroy ioctls Ben Widawsky
2012-03-29 19:35   ` Daniel Vetter
2012-03-30 18:55     ` Ben Widawsky
2012-03-30 19:16       ` Daniel Vetter
2012-03-18 20:39 ` [PATCH 14/18] drm/i915/context: switch contexts with execbuf2 Ben Widawsky
2012-03-29 19:38   ` Daniel Vetter
2012-03-30 18:58     ` Ben Widawsky
2012-03-30 19:20       ` Daniel Vetter
2012-03-18 20:39 ` [PATCH 15/18] drm/i915/context: add params Ben Widawsky
2012-03-18 20:39 ` [PATCH 16/18] drm/i915/context: anonymous context interfaces Ben Widawsky
2012-03-29 19:42   ` Daniel Vetter
2012-03-18 20:39 ` [PATCH 17/18] drm/i915: Ironlake rc6 can use " Ben Widawsky
2012-03-29 19:47   ` Daniel Vetter
2012-03-18 20:39 ` [PATCH 18/18] drm/i915: try to enable rc6 on Ironlake... again Ben Widawsky
2012-03-19  3:47 ` [PATCH 00/18] i915 HW Context Support Ben Widawsky
2012-03-19 10:14 ` Daniel Vetter
2012-03-29 19:51   ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1332103198-25852-7-git-send-email-ben@bwidawsk.net \
    --to=ben@bwidawsk.net \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.