Skip to contentSkip to conversation

drm/i915: Add a debugfs file to dump complete context

PATCH In review Arun Siluvery 3 participants 3 messages Aug 25, 2016 – Aug 26, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Add a debugfs file to dump complete context

From: Armin Reese <[email protected]>

A 'cat' of the debugfs file i915_dump_lrc, dumps only the first 0x600(1536) bytes of each ring's register state context. It does not provide information about the remaining portion of the register state context. This patch adds new file i915_dump_lrc_complete which displays full register state context. Being able to view the latter in its entirety will be very useful in debugging issues arising from incorrect context setup.

i915_dum_lrc still provides a snapshot of the context image.

v2: Since most of the content in some pages are mostly zeros, contiguous sequence of zeros are skipped in the output.

---
 drivers/gpu/drm/i915/i915_debugfs.c | 70 ++++++++++++++++++++++++++++++-------
 1 file changed, 58 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +58 -12
index 7d7b4d9..f4b5879 100644
@@ -1969,13 +1969,20 @@ static int i915_context_status(struct seq_file *m, void *unused)
 	return 0;
 }
 
+enum {
+	LRC_CONTEXT_DUMP,  /* First PAGE size bytes of register state ctx */
+	FULL_CONTEXT_DUMP, /* Full context */
+};
+
 static void i915_dump_lrc_obj(struct seq_file *m,
 			      struct i915_gem_context *ctx,
-			      struct intel_engine_cs *engine)
+			      struct intel_engine_cs *engine,
+			      unsigned int flags)
 {
 	struct i915_vma *vma = ctx->engine[engine->id].state;
 	struct page *page;
-	int j;
+	struct sg_page_iter sg_iter;
+	int i;
 
 	seq_printf(m, "CONTEXT: %s %u\n", engine->name, ctx->hw_id);
 
@@ -1993,18 +2000,53 @@ static void i915_dump_lrc_obj(struct seq_file *m,
 		return;
 	}
 
+	i = 0;
 	page = i915_gem_object_get_page(vma->obj, LRC_STATE_PN);
-	if (page) {
-		u32 *reg_state = kmap_atomic(page);
+	for_each_sg_page(vma->pages->sgl, &sg_iter, vma->pages->nents, 0) {
+		int j;
+		u32 *reg_state;
+		int run_length = 0;
+		u32 data_size = (flags == LRC_CONTEXT_DUMP) ? 0x600 : PAGE_SIZE;
+		unsigned long ggtt_offset = i915_ggtt_offset(vma);
+		unsigned long page_offset = ggtt_offset + i*PAGE_SIZE;
+
+		if (flags == LRC_CONTEXT_DUMP && i > LRC_STATE_PN)
+			break;
 
-		for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) {
-			seq_printf(m,
-				   "\t[0x%04x] 0x%08x 0x%08x 0x%08x 0x%08x\n",
-				   j * 4,
-				   reg_state[j], reg_state[j + 1],
+		page = sg_page_iter_page(&sg_iter);
+		if (WARN_ON(page == NULL))
+			break;
+
+		reg_state = kmap_atomic(page);
+
+		seq_printf(m, "Context object page: %d\n", i);
+		for (j = 0; j < data_size / sizeof(u32); j += 4) {
+			if (reg_state[j + 0] == 0 && reg_state[j + 1] == 0 &&
+			    reg_state[j + 2] == 0 && reg_state[j + 3] == 0) {
+				run_length += 4;
+				continue;
+			}
+
+			if (run_length) {
+				seq_printf(m, "\t[0x%08lx - 0x%08lx]: 0x00000000\n",
+					   page_offset + (j * 4) - (run_length * 4),
+					   page_offset + (j * 4) - 1);
+				run_length = 0;
+			}
+
+			seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n",
+				   page_offset + (j * 4),
+				   reg_state[j + 0], reg_state[j + 1],
 				   reg_state[j + 2], reg_state[j + 3]);
 		}
+		/* zeros in the whole page */
+		if (run_length) {
+			seq_printf(m, "\t[0x%08lx - 0x%08lx]: 0x00000000\n",
+				   page_offset, page_offset + data_size - 1);
+			run_length = 0;
+		}
 		kunmap_atomic(reg_state);
+		++i;
 	}
 
 	seq_putc(m, '\n');
@@ -2012,10 +2054,12 @@ static void i915_dump_lrc_obj(struct seq_file *m,
 
 static int i915_dump_lrc(struct seq_file *m, void *unused)
 {
+	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_i915_private *dev_priv = node_to_i915(m->private);
 	struct drm_device *dev = &dev_priv->drm;
 	struct intel_engine_cs *engine;
 	struct i915_gem_context *ctx;
+	uintptr_t flags = (uintptr_t) node->info_ent->data;
 	int ret;
 
 	if (!i915.enable_execlists) {
@@ -2027,9 +2071,10 @@ static int i915_dump_lrc(struct seq_file *m, void *unused)
 	if (ret)
 		return ret;
 
-	list_for_each_entry(ctx, &dev_priv->context_list, link)
+	list_for_each_entry(ctx, &dev_priv->context_list, link) {
 		for_each_engine(engine, dev_priv)
-			i915_dump_lrc_obj(m, ctx, engine);
+			i915_dump_lrc_obj(m, ctx, engine, flags);
+	}
 
 	mutex_unlock(&dev->struct_mutex);
 
@@ -5286,7 +5331,8 @@ static const struct drm_info_list i915_debugfs_list[] = {
 	{"i915_vbt", i915_vbt, 0},
 	{"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
 	{"i915_context_status", i915_context_status, 0},
-	{"i915_dump_lrc", i915_dump_lrc, 0},
+	{"i915_dump_lrc", i915_dump_lrc, 0, (void *)LRC_CONTEXT_DUMP},
+	{"i915_dump_lrc_complete", i915_dump_lrc, 0, (void *)FULL_CONTEXT_DUMP},
 	{"i915_execlists", i915_execlists, 0},
 	{"i915_forcewake_domains", i915_forcewake_domains, 0},
 	{"i915_swizzle_info", i915_swizzle_info, 0},
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 8 lines · Arun Siluvery

From: Armin Reese <[email protected]>

A 'cat' of the debugfs file i915_dump_lrc, dumps only the first 0x600(1536) bytes of each ring's register state context. It does not provide information about the remaining portion of the register state context. This patch adds new file i915_dump_lrc_complete which displays full register state context. Being able to view the latter in its entirety will be very useful in debugging issues arising from incorrect context setup.

When I've been debugging context problems, I just dumped the image via the CONTEXT_GETPARAM ioctl. Helped when looking at problems in situ and I could then compare the images across the break point.

Dumping every page of every context object is not going to scale well, my basic fear is that you will lose the information you need amongst the noise. Especially as you will quickly run into the limits of seq_file... -Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

✗ Fi.CI.BAT: warning for drm/i915: Add a debugfs file to dump complete context

In reply to Arun Siluvery
== Series Details ==

== Series Details ==

Series: drm/i915: Add a debugfs file to dump complete context
URL : https://patchwork.freedesktop.org/series/11568/
State : warning

== Summary ==

Series 11568v1 drm/i915: Add a debugfs file to dump complete context
http://patchwork.freedesktop.org/api/1.0/series/11568/revisions/1/mbox/

Test drv_hangman:

        Subgroup error-state-basic:
                dmesg-warn -> PASS       (fi-snb-2600)
Test gem_basic:
        Subgroup bad-close:
                pass       -> DMESG-WARN (fi-snb-2600)
Test gem_exec_gttfill:
        Subgroup basic:
                pass       -> SKIP       (fi-snb-2520m)
                pass       -> SKIP       (fi-snb-2600)
                pass       -> SKIP       (fi-ivb-3520m)
fi-bdw-5557u     total:252  pass:235  dwarn:0   dfail:0   fail:2   skip:15 
fi-byt-n2820     total:252  pass:207  dwarn:0   dfail:0   fail:3   skip:42 
fi-hsw-4770r     total:252  pass:224  dwarn:0   dfail:0   fail:2   skip:26 
fi-ivb-3520m     total:252  pass:219  dwarn:0   dfail:0   fail:1   skip:32 
fi-skl-6260u     total:252  pass:236  dwarn:0   dfail:0   fail:2   skip:14 
fi-skl-6700k     total:252  pass:222  dwarn:0   dfail:0   fail:2   skip:28 
fi-snb-2520m     total:252  pass:198  dwarn:8   dfail:0   fail:2   skip:44 
fi-snb-2600      total:252  pass:198  dwarn:8   dfail:0   fail:2   skip:44 

fi-bsw-n3050 failed to connect after reboot
fi-hsw-4770k failed to collect. IGT log at Patchwork_2432/fi-hsw-4770k/igt.log

Results at /archive/results/CI_IGT_test/Patchwork_2432/

30de872fd5cf71a51994375fb4f76856c05b1c4c drm-intel-nightly: 2016y-08m-25d-11h-15m-39s UTC integration manifest 9e755d9 drm/i915: Add a debugfs file to dump complete context

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx