[Intel-gfx] [PATCH] Implement gem object search by gtt offset

Ben Gamari bgamari at gmail.com
Thu Jan 15 04:11:47 CET 2009


When dumping a batch buffer, we need to find its gem object so that we
may pin it. Here we look through active_list, inactive_list, and
flushing_list looking for an object with a valid and matching gtt_offset
---
 drivers/gpu/drm/i915/i915_gem_debugfs.c |   47 +++++++++++++++++++++++++------
 1 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_debugfs.c b/drivers/gpu/drm/i915/i915_gem_debugfs.c
index 10ca9ae..e8ca71b 100644
--- a/drivers/gpu/drm/i915/i915_gem_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_gem_debugfs.c
@@ -617,7 +617,32 @@ static int dump_cmd(struct seq_file *m, uint32_t cmd, int count)
 	return ret;
 }
 
-static void dump_cmds (struct seq_file      *m,
+static struct drm_i915_gem_object* find_batch_buffer_in_list(struct list_head *head, uint32_t gtt_offset)
+{
+	struct drm_i915_gem_object* obj_priv;
+
+	list_for_each_entry(obj_priv, head, list) {
+		if (obj_priv->gtt_space && gtt_offset == obj_priv->gtt_offset) 
+			return obj_priv;
+	}
+	return NULL;
+}
+
+static struct drm_i915_gem_object* find_batch_buffer(struct drm_device *dev, uint32_t gtt_offset)
+{
+	struct drm_i915_gem_object* obj_priv;
+	drm_i915_private_t *dev_priv = dev->dev_private;
+
+	obj_priv = find_batch_buffer_in_list(&dev_priv->mm.active_list, gtt_offset);
+	if (!obj_priv)
+		obj_priv = find_batch_buffer_in_list(&dev_priv->mm.inactive_list, gtt_offset);
+	if (!obj_priv)
+		obj_priv = find_batch_buffer_in_list(&dev_priv->mm.flushing_list, gtt_offset);
+	return obj_priv;
+}
+
+static void dump_cmds (struct seq_file	*m,
+		struct drm_device	*dev,
 		volatile unsigned char	*virt,
 		uint32_t		start,
 		uint32_t		stop,
@@ -646,7 +671,6 @@ static void dump_cmds (struct seq_file      *m,
 		if (ring == acthd)
 			seq_printf(m, "****");
 
-		DRM_INFO("\t%08x: %08x", ring, *(volatile unsigned int*) (virt + ring));
 		if (ring == cmd) {
 			ptr = (volatile uint32_t *) (virt + ring);
 			data = *ptr;
@@ -661,13 +685,18 @@ static void dump_cmds (struct seq_file      *m,
 			if ( (data & batch_start_mask) == batch_start_cmd) {
 				uint32_t batch = ptr[1] & ~3;
 				uint32_t addr_type = (ptr[0] & (1 << 7));
+				struct drm_i915_gem_object *obj_priv = find_batch_buffer(dev, batch);
+
 				seq_printf(m, "\t%08x: %08x\n", (ring + 4) & mask, batch);
-				seq_printf(m, "Batch buffer at 0x%08x (%s) {\n", batch, addr_type ? "GfxMem" : "PhysMem");
-				/* TODO: Implement batch buffer dumping
-				   dump_cmds(m, acthd);
-				   ring = (ring + (count -1)*4) & mask;
-				 */
-				seq_printf(m, "}\n");
+				seq_printf(m, "Batch buffer at 0x%08x (%s)\n", batch, addr_type ? "GfxMem" : "PhysMem");
+				if (obj_priv) {
+					unsigned char *virt = obj_priv->obj;
+					/* TODO: Implement batch buffer dumping */
+					seq_printf(m, "{\n");
+					dump_cmds(m, dev, (unsigned char*)batch, 0, 4096, mask, acthd);
+					ring = (ring + (count -1)*4) & mask;
+					seq_printf(m, "}\n");
+				}
 			}
 			cmd = (cmd + count * 4) & mask;
 		} else
@@ -730,7 +759,7 @@ static void dump_ring(struct seq_file *m, struct drm_device *dev, uint32_t acthd
 			break;
 	}
 
-	dump_cmds(m, virt, cmd, head, mask, acthd);
+	dump_cmds(m, dev, virt, cmd, head, mask, acthd);
 	seq_printf(m, "Ring end\n");
 }
 
-- 
1.6.0.6




More information about the Intel-gfx mailing list