diff mbox

[RFC,1/2] drm/i915: abstract error object dumping

Message ID 9c695fb1fc64ccb6d66242ef486aec5b28486d11.1366359294.git.jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jani Nikula April 19, 2013, 8:16 a.m. UTC
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/i915_debugfs.c |   34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)
diff mbox

Patch

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,