All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesse Barnes <jbarnes@virtuousgeek.org>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 2/2] drm/i915: add idle/busy tracepoints
Date: Fri, 18 Mar 2011 10:56:15 -0700	[thread overview]
Message-ID: <1300470975-2521-2-git-send-email-jbarnes@virtuousgeek.org> (raw)
In-Reply-To: <1300470975-2521-1-git-send-email-jbarnes@virtuousgeek.org>

Add trace points for when the GPU goes from idle to busy and vice-versa.
Also trace when we start to idle the GPU and when it finally does idle
(this could take awhile if the ring is full of commands).

Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
---
 drivers/gpu/drm/i915/i915_drv.h         |    4 +++
 drivers/gpu/drm/i915/i915_gem.c         |    4 +++
 drivers/gpu/drm/i915/i915_irq.c         |    5 ++++
 drivers/gpu/drm/i915/i915_trace.h       |   35 +++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_ringbuffer.c |    6 +++++
 5 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index c8a21ce..adff483 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -674,6 +674,10 @@ typedef struct drm_i915_private {
 	int lvds_downclock;
 	struct work_struct idle_work;
 	struct timer_list idle_timer;
+
+	bool gpu_busy;
+	unsigned long gpu_busy_start;
+
 	bool busy;
 	u16 orig_clock;
 	int child_dev_num;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index ac23dcf..18534d7 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2208,6 +2208,8 @@ i915_gpu_idle(struct drm_device *dev)
 	bool lists_empty;
 	int ret, i;
 
+	trace_i915_gpu_idle_start(dev);
+
 	lists_empty = (list_empty(&dev_priv->mm.flushing_list) &&
 		       list_empty(&dev_priv->mm.active_list));
 	if (lists_empty)
@@ -2220,6 +2222,8 @@ i915_gpu_idle(struct drm_device *dev)
 			return ret;
 	}
 
+	trace_i915_gpu_idle_end(dev);
+
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 346dd85..0d3cc62 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -365,6 +365,11 @@ static void notify_ring(struct drm_device *dev,
 	dev_priv->hangcheck_count = 0;
 	mod_timer(&dev_priv->hangcheck_timer,
 		  jiffies + msecs_to_jiffies(DRM_I915_HANGCHECK_PERIOD));
+
+	if (I915_READ_HEAD(ring) == I915_READ_TAIL(ring)) {
+		dev_priv->gpu_busy = false;
+		trace_i915_gpu_busy_end(dev_priv->dev);
+	}
 }
 
 static void gen6_pm_irq_handler(struct drm_device *dev)
diff --git a/drivers/gpu/drm/i915/i915_trace.h b/drivers/gpu/drm/i915/i915_trace.h
index e102c76..1eb63a6 100644
--- a/drivers/gpu/drm/i915/i915_trace.h
+++ b/drivers/gpu/drm/i915/i915_trace.h
@@ -410,6 +410,41 @@ TRACE_EVENT(i915_reg_rw,
 		     (u32)(__entry->val >> 32))
 );
 
+DECLARE_EVENT_CLASS(i915_gpu_global,
+		    TP_PROTO(struct drm_device *dev),
+		    TP_ARGS(dev),
+
+		    TP_STRUCT__entry(
+			    __field(int, dev)
+			    ),
+
+		    TP_fast_assign(
+			    __entry->dev = dev->primary->index;
+			    ),
+
+		    TP_printk("dev=%d", __entry->dev)
+);
+
+DEFINE_EVENT(i915_gpu_global, i915_gpu_idle_start,
+	    TP_PROTO(struct drm_device *dev),
+	    TP_ARGS(dev)
+);
+
+DEFINE_EVENT(i915_gpu_global, i915_gpu_idle_end,
+	    TP_PROTO(struct drm_device *dev),
+	    TP_ARGS(dev)
+);
+
+DEFINE_EVENT(i915_gpu_global, i915_gpu_busy_start,
+	    TP_PROTO(struct drm_device *dev),
+	    TP_ARGS(dev)
+);
+
+DEFINE_EVENT(i915_gpu_global, i915_gpu_busy_end,
+	    TP_PROTO(struct drm_device *dev),
+	    TP_ARGS(dev)
+);
+
 TRACE_EVENT(i915_pkg_power,
 	    TP_PROTO(unsigned long power),
 	    TP_ARGS(power),
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 789c478..530d9c3 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -1089,6 +1089,12 @@ gen6_ring_dispatch_execbuffer(struct intel_ring_buffer *ring,
        intel_ring_emit(ring, offset);
        intel_ring_advance(ring);
 
+       if (!dev_priv->gpu_busy) {
+	       dev_priv->gpu_busy = true;
+	       trace_i915_gpu_busy_start(ring->dev);
+	       dev_priv->gpu_busy_start = jiffies;
+       }
+
        return 0;
 }
 
-- 
1.7.1

  reply	other threads:[~2011-03-18 17:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-18 17:56 [PATCH 1/2] drm/i915: add SNB power monitoring Jesse Barnes
2011-03-18 17:56 ` Jesse Barnes [this message]
2011-03-18 18:12   ` [PATCH 2/2] drm/i915: add idle/busy tracepoints Chris Wilson
2011-03-18 18:18     ` Jesse Barnes

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=1300470975-2521-2-git-send-email-jbarnes@virtuousgeek.org \
    --to=jbarnes@virtuousgeek.org \
    --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.