[Intel-gfx] [PATCH 2/2] drm/i915: add idle/busy tracepoints

Jesse Barnes jbarnes at virtuousgeek.org
Fri Mar 18 18:56:15 CET 2011


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




More information about the Intel-gfx mailing list