[Intel-gfx] [RFC PATCH 1/2] drm/i915: abstract error object dumping

Jani Nikula jani.nikula at intel.com
Fri Apr 19 10:16:10 CEST 2013


Signed-off-by: Jani Nikula <jani.nikula at intel.com>
---
 drivers/gpu/drm/i915/i915_debugfs.c |   34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 367b534..0b3b9ac 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -678,6 +678,18 @@ struct i915_error_state_file_priv {
 	struct drm_i915_error_state *error;
 };
 
+static void i915_dump_error_object(struct seq_file *m, struct drm_i915_error_object *obj)
+{
+	int page, elt, offset = 0;
+
+	for (page = 0; page < obj->page_count; page++) {
+		for (elt = 0; elt < PAGE_SIZE / 4; elt++) {
+			seq_printf(m, "%08x :  %08x\n", offset, obj->pages[page][elt]);
+			offset += 4;
+		}
+	}
+}
+
 static int i915_error_state(struct seq_file *m, void *unused)
 {
 	struct i915_error_state_file_priv *error_priv = m->private;
@@ -685,7 +697,7 @@ static int i915_error_state(struct seq_file *m, void *unused)
 	drm_i915_private_t *dev_priv = dev->dev_private;
 	struct drm_i915_error_state *error = error_priv->error;
 	struct intel_ring_buffer *ring;
-	int i, j, page, offset, elt;
+	int i, j;
 
 	if (!error) {
 		seq_printf(m, "no error state collected\n");
@@ -737,13 +749,7 @@ static int i915_error_state(struct seq_file *m, void *unused)
 			seq_printf(m, "%s --- gtt_offset = 0x%08x\n",
 				   dev_priv->ring[i].name,
 				   obj->gtt_offset);
-			offset = 0;
-			for (page = 0; page < obj->page_count; page++) {
-				for (elt = 0; elt < PAGE_SIZE/4; elt++) {
-					seq_printf(m, "%08x :  %08x\n", offset, obj->pages[page][elt]);
-					offset += 4;
-				}
-			}
+			i915_dump_error_object(m, obj);
 		}
 
 		if (error->ring[i].num_requests) {
@@ -762,23 +768,15 @@ static int i915_error_state(struct seq_file *m, void *unused)
 			seq_printf(m, "%s --- ringbuffer = 0x%08x\n",
 				   dev_priv->ring[i].name,
 				   obj->gtt_offset);
-			offset = 0;
-			for (page = 0; page < obj->page_count; page++) {
-				for (elt = 0; elt < PAGE_SIZE/4; elt++) {
-					seq_printf(m, "%08x :  %08x\n",
-						   offset,
-						   obj->pages[page][elt]);
-					offset += 4;
-				}
-			}
+			i915_dump_error_object(m, obj);
 		}
 
 		obj = error->ring[i].ctx;
 		if (obj) {
+			int elt, offset = 0;
 			seq_printf(m, "%s --- HW Context = 0x%08x\n",
 				   dev_priv->ring[i].name,
 				   obj->gtt_offset);
-			offset = 0;
 			for (elt = 0; elt < PAGE_SIZE/16; elt += 4) {
 				seq_printf(m, "[%04x] %08x %08x %08x %08x\n",
 					   offset,
-- 
1.7.10.4




More information about the Intel-gfx mailing list