* [PATCH] drm/i915: Add debugfs file to dump entire logical context
@ 2014-11-04 17:19 armin.c.reese
2014-11-05 12:33 ` Daniel Vetter
0 siblings, 1 reply; 4+ messages in thread
From: armin.c.reese @ 2014-11-04 17:19 UTC (permalink / raw)
To: intel-gfx
From: Armin Reese <armin.c.reese@intel.com>
The new 'i915_context_dump' file generates a hex dump of the
entire logical context DRM object. It is useful for
validating the contents of the default context set up by
the golden state batch buffer.
v1 - Reuse function i915_dump_lrc() instead of i915_context_status().
Separated display of HW Status Page from full Register State
Context
Signed-off-by: Armin Reese <armin.c.reese@intel.com>
---
drivers/gpu/drm/i915/i915_debugfs.c | 97 +++++++++++++++++++++++++++++++------
1 file changed, 81 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 0a69813..9bf519e 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -46,6 +46,11 @@ enum {
PINNED_LIST,
};
+enum {
+ LRC_CONTEXT_DUMP, /* First 1536 bytes of register state ctxt */
+ FULL_CONTEXT_DUMP, /* Full context (HW status + reg state ctxt */
+};
+
static const char *yesno(int v)
{
return v ? "yes" : "no";
@@ -119,6 +124,48 @@ static inline const char *get_global_flag(struct drm_i915_gem_object *obj)
return i915_gem_obj_to_ggtt(obj) ? "g" : " ";
}
+/*
+ * Dump contents of GEM object to the screen. 8 DWORDs per line
+ */
+
+static void
+dump_32_obj(struct seq_file *m, struct drm_i915_gem_object *obj,
+ int start_pg, int num_pgs)
+{
+ struct page *page;
+ struct sg_page_iter sg_iter;
+ size_t pg_offset, obj_offset = 0;
+ uint32_t *pg_ptr, *curr_ptr;
+ int i, pg_cnt = 0;
+
+ for_each_sg_page(obj->pages->sgl, &sg_iter,
+ obj->pages->nents, start_pg) {
+ page = sg_page_iter_page(&sg_iter);
+
+ pg_ptr = (uint32_t *)kmap_atomic(page);
+ curr_ptr = pg_ptr;
+ pg_offset = 0;
+
+ while (pg_offset < PAGE_SIZE) {
+ seq_printf(m, "0x%08lx: ", obj_offset);
+ for (i = 0; i < 8; i++) {
+ seq_printf(m, "0x%08x ", *curr_ptr);
+ curr_ptr++;
+ }
+ seq_puts(m, "\n");
+
+ pg_offset += 8 * sizeof(uint32_t);
+ obj_offset += 8 * sizeof(uint32_t);
+ }
+
+ kunmap_atomic(pg_ptr);
+
+ if ((num_pgs != -1) &&
+ (++pg_cnt >= num_pgs))
+ break;
+ }
+}
+
static void
describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
{
@@ -1773,9 +1820,10 @@ static int i915_context_status(struct seq_file *m, void *unused)
return 0;
}
-static int i915_dump_lrc(struct seq_file *m, void *unused)
+static int i915_dump_lrc(struct seq_file *m, void *data)
{
struct drm_info_node *node = (struct drm_info_node *) m->private;
+ uintptr_t dump_flag = (uintptr_t) node->info_ent->data;
struct drm_device *dev = node->minor->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_engine_cs *ring;
@@ -1795,24 +1843,40 @@ static int i915_dump_lrc(struct seq_file *m, void *unused)
for_each_ring(ring, dev_priv, i) {
struct drm_i915_gem_object *ctx_obj = ctx->engine[i].state;
- if (ring->default_context == ctx)
+ if ((ring->default_context == ctx) &&
+ (dump_flag == LRC_CONTEXT_DUMP))
continue;
+ /*
+ * Hardware Status Page is in first page of context
+ * object. Register state context begins on second
+ * page.
+ */
if (ctx_obj) {
- struct page *page = i915_gem_object_get_page(ctx_obj, 1);
- uint32_t *reg_state = kmap_atomic(page);
- int j;
-
- seq_printf(m, "CONTEXT: %s %u\n", ring->name,
- intel_execlists_ctx_id(ctx_obj));
-
- for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) {
- seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n",
- i915_gem_obj_ggtt_offset(ctx_obj) + 4096 + (j * 4),
- reg_state[j], reg_state[j + 1],
- reg_state[j + 2], reg_state[j + 3]);
+ if (dump_flag == LRC_CONTEXT_DUMP) {
+ struct page *page = i915_gem_object_get_page(ctx_obj, 1);
+ uint32_t *reg_state = kmap_atomic(page);
+ int j;
+
+ seq_printf(m, "CONTEXT: %s %u\n", ring->name,
+ intel_execlists_ctx_id(ctx_obj));
+
+ for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) {
+ seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n",
+ i915_gem_obj_ggtt_offset(ctx_obj) + 4096 + (j * 4),
+ reg_state[j], reg_state[j + 1],
+ reg_state[j + 2], reg_state[j + 3]);
+ }
+ kunmap_atomic(reg_state);
+ } else if (dump_flag == FULL_CONTEXT_DUMP) {
+ seq_printf(m, "Hardware Status Page: %s %u\n",
+ ring->name,
+ intel_execlists_ctx_id(ctx_obj));
+ dump_32_obj(m, ctx_obj, 0, 1);
+ seq_printf(m, "Register State Context: %s %u\n", ring->name,
+ intel_execlists_ctx_id(ctx_obj));
+ dump_32_obj(m, ctx_obj, 1, -1);
}
- kunmap_atomic(reg_state);
seq_putc(m, '\n');
}
@@ -4188,7 +4252,8 @@ static const struct drm_info_list i915_debugfs_list[] = {
{"i915_opregion", i915_opregion, 0},
{"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
{"i915_context_status", i915_context_status, 0},
- {"i915_dump_lrc", i915_dump_lrc, 0},
+ {"i915_context_dump", i915_dump_lrc, 0, (void *)FULL_CONTEXT_DUMP},
+ {"i915_dump_lrc", i915_dump_lrc, 0, (void *)LRC_CONTEXT_DUMP},
{"i915_execlists", i915_execlists, 0},
{"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info, 0},
{"i915_swizzle_info", i915_swizzle_info, 0},
--
1.9.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH] drm/i915: Add debugfs file to dump entire logical context
@ 2014-10-30 23:03 armin.c.reese
2014-10-31 16:18 ` Volkin, Bradley D
0 siblings, 1 reply; 4+ messages in thread
From: armin.c.reese @ 2014-10-30 23:03 UTC (permalink / raw)
To: intel-gfx
From: Armin Reese <armin.c.reese@intel.com>
The new 'i915_context_dump' file generates a hex dump of the
entire logical context DRM object. It is useful for
validating the contents of the default context set up by
the golden state batch buffer.
Signed-off-by: Armin Reese <armin.c.reese@intel.com>
---
drivers/gpu/drm/i915/i915_debugfs.c | 92 ++++++++++++++++++++++++++++++-------
1 file changed, 76 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index a79f83c..7807c14 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -46,6 +46,11 @@ enum {
PINNED_LIST,
};
+enum {
+ LRC_CONTEXT_DUMP,
+ FULL_CONTEXT_DUMP,
+};
+
static const char *yesno(int v)
{
return v ? "yes" : "no";
@@ -120,6 +125,52 @@ static inline const char *get_global_flag(struct drm_i915_gem_object *obj)
}
static void
+dump_32_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
+{
+ struct page *page;
+ size_t size; /* In bytes */
+ size_t start_dword, end_dword, end_row_dword; /* In uint32_t offsets */
+ int i, num_pages;
+ uint32_t *obj_ptr;
+
+ if (i915_gem_object_get_pages(obj))
+ return;
+
+ size = obj->base.size; /* In bytes */
+ num_pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
+
+ for (i = 0; i < num_pages; i++) {
+ page = i915_gem_object_get_page(obj, i);
+ drm_clflush_pages(&page, 1);
+
+ start_dword = (i * PAGE_SIZE) / sizeof(uint32_t);
+ end_dword = start_dword + (PAGE_SIZE / sizeof(uint32_t));
+ if ((end_dword * sizeof(uint32_t)) > size)
+ end_dword = size / sizeof(uint32_t);
+
+ obj_ptr = (uint32_t *)kmap_atomic(page);
+
+ while (start_dword < end_dword) {
+ end_row_dword = start_dword + 8;
+ if (end_row_dword > end_dword)
+ end_row_dword = end_dword;
+ seq_printf(m, "0x%08lx: ",
+ start_dword * sizeof(uint32_t));
+ while (start_dword < end_row_dword) {
+ seq_printf(m, "0x%08x ",
+ *(obj_ptr +
+ (start_dword &
+ (PAGE_SIZE - 1))));
+ start_dword++;
+ }
+ seq_puts(m, "\n");
+ }
+
+ kunmap_atomic(obj_ptr);
+ }
+}
+
+static void
describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
{
struct i915_vma *vma;
@@ -1773,9 +1824,10 @@ static int i915_context_status(struct seq_file *m, void *unused)
return 0;
}
-static int i915_dump_lrc(struct seq_file *m, void *unused)
+static int i915_dump_lrc(struct seq_file *m, void *data)
{
struct drm_info_node *node = (struct drm_info_node *) m->private;
+ uintptr_t dump_flag = (uintptr_t) node->info_ent->data;
struct drm_device *dev = node->minor->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_engine_cs *ring;
@@ -1795,24 +1847,31 @@ static int i915_dump_lrc(struct seq_file *m, void *unused)
for_each_ring(ring, dev_priv, i) {
struct drm_i915_gem_object *ctx_obj = ctx->engine[i].state;
- if (ring->default_context == ctx)
+ if ((ring->default_context == ctx) &&
+ (dump_flag == LRC_CONTEXT_DUMP))
continue;
if (ctx_obj) {
- struct page *page = i915_gem_object_get_page(ctx_obj, 1);
- uint32_t *reg_state = kmap_atomic(page);
- int j;
-
- seq_printf(m, "CONTEXT: %s %u\n", ring->name,
- intel_execlists_ctx_id(ctx_obj));
-
- for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) {
- seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n",
- i915_gem_obj_ggtt_offset(ctx_obj) + 4096 + (j * 4),
- reg_state[j], reg_state[j + 1],
- reg_state[j + 2], reg_state[j + 3]);
+ if (dump_flag == LRC_CONTEXT_DUMP) {
+ struct page *page = i915_gem_object_get_page(ctx_obj, 1);
+ uint32_t *reg_state = kmap_atomic(page);
+ int j;
+
+ seq_printf(m, "CONTEXT: %s %u\n", ring->name,
+ intel_execlists_ctx_id(ctx_obj));
+
+ for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) {
+ seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n",
+ i915_gem_obj_ggtt_offset(ctx_obj) + 4096 + (j * 4),
+ reg_state[j], reg_state[j + 1],
+ reg_state[j + 2], reg_state[j + 3]);
+ }
+ kunmap_atomic(reg_state);
+ } else if (dump_flag == FULL_CONTEXT_DUMP) {
+ seq_printf(m, "Full Context Dump: %s %u\n", ring->name,
+ intel_execlists_ctx_id(ctx_obj));
+ dump_32_obj(m, ctx_obj);
}
- kunmap_atomic(reg_state);
seq_putc(m, '\n');
}
@@ -4187,7 +4246,8 @@ static const struct drm_info_list i915_debugfs_list[] = {
{"i915_opregion", i915_opregion, 0},
{"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
{"i915_context_status", i915_context_status, 0},
- {"i915_dump_lrc", i915_dump_lrc, 0},
+ {"i915_context_dump", i915_dump_lrc, 0, (void *)FULL_CONTEXT_DUMP},
+ {"i915_dump_lrc", i915_dump_lrc, 0, (void *)LRC_CONTEXT_DUMP},
{"i915_execlists", i915_execlists, 0},
{"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info, 0},
{"i915_swizzle_info", i915_swizzle_info, 0},
--
1.9.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] drm/i915: Add debugfs file to dump entire logical context
2014-10-30 23:03 armin.c.reese
@ 2014-10-31 16:18 ` Volkin, Bradley D
0 siblings, 0 replies; 4+ messages in thread
From: Volkin, Bradley D @ 2014-10-31 16:18 UTC (permalink / raw)
To: armin.c.reese@intel.com; +Cc: intel-gfx@lists.freedesktop.org
On Thu, Oct 30, 2014 at 04:03:23PM -0700, armin.c.reese@intel.com wrote:
> From: Armin Reese <armin.c.reese@intel.com>
>
> The new 'i915_context_dump' file generates a hex dump of the
> entire logical context DRM object. It is useful for
> validating the contents of the default context set up by
> the golden state batch buffer.
This patch needs a changelog providing brief descriptions of what
has changed in each new version that you send.
>
> Signed-off-by: Armin Reese <armin.c.reese@intel.com>
> ---
> drivers/gpu/drm/i915/i915_debugfs.c | 92 ++++++++++++++++++++++++++++++-------
> 1 file changed, 76 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index a79f83c..7807c14 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -46,6 +46,11 @@ enum {
> PINNED_LIST,
> };
>
> +enum {
> + LRC_CONTEXT_DUMP,
I think this should be something like REG_STATE_CONTEXT_DUMP or similar.
It better describes what we're actually dumping in this case.
> + FULL_CONTEXT_DUMP,
> +};
> +
> static const char *yesno(int v)
> {
> return v ? "yes" : "no";
> @@ -120,6 +125,52 @@ static inline const char *get_global_flag(struct drm_i915_gem_object *obj)
> }
>
> static void
> +dump_32_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
> +{
> + struct page *page;
> + size_t size; /* In bytes */
> + size_t start_dword, end_dword, end_row_dword; /* In uint32_t offsets */
> + int i, num_pages;
> + uint32_t *obj_ptr;
> +
> + if (i915_gem_object_get_pages(obj))
> + return;
> +
> + size = obj->base.size; /* In bytes */
> + num_pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
> +
> + for (i = 0; i < num_pages; i++) {
> + page = i915_gem_object_get_page(obj, i);
I believe the preferred way to walk the list of pages is:
struct sg_page_iter sg_iter;
for_each_sg_page(obj->pages->sgl, &sg_iter, obj->pages->nents, 0) {
page = sg_page_iter_page(&sg_iter);
If we make this change, num_pages is no longer used.
> + drm_clflush_pages(&page, 1);
> +
> + start_dword = (i * PAGE_SIZE) / sizeof(uint32_t);
> + end_dword = start_dword + (PAGE_SIZE / sizeof(uint32_t));
> + if ((end_dword * sizeof(uint32_t)) > size)
> + end_dword = size / sizeof(uint32_t);
The size of a GEM object is always a multiple of the page size, so you
can assume that it's safe to just dump the entirety of each page in the
object's page list. I think you can also use this fact to simplify the
looping below. And you might consider doing obj_ptr++ instead of the
bitwise 'and'.
Brad
> +
> + obj_ptr = (uint32_t *)kmap_atomic(page);
> +
> + while (start_dword < end_dword) {
> + end_row_dword = start_dword + 8;
> + if (end_row_dword > end_dword)
> + end_row_dword = end_dword;
> + seq_printf(m, "0x%08lx: ",
> + start_dword * sizeof(uint32_t));
> + while (start_dword < end_row_dword) {
> + seq_printf(m, "0x%08x ",
> + *(obj_ptr +
> + (start_dword &
> + (PAGE_SIZE - 1))));
> + start_dword++;
> + }
> + seq_puts(m, "\n");
> + }
> +
> + kunmap_atomic(obj_ptr);
> + }
> +}
> +
> +static void
> describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
> {
> struct i915_vma *vma;
> @@ -1773,9 +1824,10 @@ static int i915_context_status(struct seq_file *m, void *unused)
> return 0;
> }
>
> -static int i915_dump_lrc(struct seq_file *m, void *unused)
> +static int i915_dump_lrc(struct seq_file *m, void *data)
> {
> struct drm_info_node *node = (struct drm_info_node *) m->private;
> + uintptr_t dump_flag = (uintptr_t) node->info_ent->data;
> struct drm_device *dev = node->minor->dev;
> struct drm_i915_private *dev_priv = dev->dev_private;
> struct intel_engine_cs *ring;
> @@ -1795,24 +1847,31 @@ static int i915_dump_lrc(struct seq_file *m, void *unused)
> for_each_ring(ring, dev_priv, i) {
> struct drm_i915_gem_object *ctx_obj = ctx->engine[i].state;
>
> - if (ring->default_context == ctx)
> + if ((ring->default_context == ctx) &&
> + (dump_flag == LRC_CONTEXT_DUMP))
> continue;
>
> if (ctx_obj) {
> - struct page *page = i915_gem_object_get_page(ctx_obj, 1);
> - uint32_t *reg_state = kmap_atomic(page);
> - int j;
> -
> - seq_printf(m, "CONTEXT: %s %u\n", ring->name,
> - intel_execlists_ctx_id(ctx_obj));
> -
> - for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) {
> - seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n",
> - i915_gem_obj_ggtt_offset(ctx_obj) + 4096 + (j * 4),
> - reg_state[j], reg_state[j + 1],
> - reg_state[j + 2], reg_state[j + 3]);
> + if (dump_flag == LRC_CONTEXT_DUMP) {
> + struct page *page = i915_gem_object_get_page(ctx_obj, 1);
> + uint32_t *reg_state = kmap_atomic(page);
> + int j;
> +
> + seq_printf(m, "CONTEXT: %s %u\n", ring->name,
> + intel_execlists_ctx_id(ctx_obj));
> +
> + for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) {
> + seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n",
> + i915_gem_obj_ggtt_offset(ctx_obj) + 4096 + (j * 4),
> + reg_state[j], reg_state[j + 1],
> + reg_state[j + 2], reg_state[j + 3]);
> + }
> + kunmap_atomic(reg_state);
> + } else if (dump_flag == FULL_CONTEXT_DUMP) {
> + seq_printf(m, "Full Context Dump: %s %u\n", ring->name,
> + intel_execlists_ctx_id(ctx_obj));
> + dump_32_obj(m, ctx_obj);
> }
> - kunmap_atomic(reg_state);
>
> seq_putc(m, '\n');
> }
> @@ -4187,7 +4246,8 @@ static const struct drm_info_list i915_debugfs_list[] = {
> {"i915_opregion", i915_opregion, 0},
> {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
> {"i915_context_status", i915_context_status, 0},
> - {"i915_dump_lrc", i915_dump_lrc, 0},
> + {"i915_context_dump", i915_dump_lrc, 0, (void *)FULL_CONTEXT_DUMP},
> + {"i915_dump_lrc", i915_dump_lrc, 0, (void *)LRC_CONTEXT_DUMP},
> {"i915_execlists", i915_execlists, 0},
> {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info, 0},
> {"i915_swizzle_info", i915_swizzle_info, 0},
> --
> 1.9.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-05 12:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-04 17:19 [PATCH] drm/i915: Add debugfs file to dump entire logical context armin.c.reese
2014-11-05 12:33 ` Daniel Vetter
-- strict thread matches above, loose matches on Subject: below --
2014-10-30 23:03 armin.c.reese
2014-10-31 16:18 ` Volkin, Bradley D
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).