From patchwork Thu Aug 27 18:26:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: arun.siluvery@linux.intel.com X-Patchwork-Id: 7086731 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D8C64BEEC1 for ; Thu, 27 Aug 2015 18:26:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EA9F420976 for ; Thu, 27 Aug 2015 18:26:14 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6CB482097D for ; Thu, 27 Aug 2015 18:26:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9BEC76EDFF; Thu, 27 Aug 2015 11:26:11 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id E700A6EDF4 for ; Thu, 27 Aug 2015 11:26:09 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 27 Aug 2015 11:26:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,422,1437462000"; d="scan'208";a="776939893" Received: from asiluver-linux.isw.intel.com ([10.102.226.117]) by fmsmga001.fm.intel.com with ESMTP; 27 Aug 2015 11:26:06 -0700 From: Arun Siluvery To: intel-gfx@lists.freedesktop.org Date: Thu, 27 Aug 2015 19:26:02 +0100 Message-Id: <1440699963-29495-1-git-send-email-arun.siluvery@linux.intel.com> X-Mailer: git-send-email 1.9.1 Cc: Mika Kuoppala Subject: [Intel-gfx] [RFC 1/2] drm/i915: Add a debugfs file to dump full ring contexts X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Armin Reese A 'cat' of the debugfs file i915_dump_lrc, dumps only the first 0x600 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 a new file i915_context_dump which displays the ring's hws page along with the ring's full register state context. Having this data in its entirety will definitely help in debugging GPU hang issues to understand the state of context. v1: Original patch v2: reuse i915_dump_lrc_obj instead of creating new fn. Signed-off-by: Armin Reese Signed-off-by: Arun Siluvery --- drivers/gpu/drm/i915/i915_debugfs.c | 73 ++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 7a28de5..9c5c42d 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 ctx */ + FULL_CONTEXT_DUMP, /* Full context (HW status + reg state ctx) */ +}; + static const char *yesno(int v) { return v ? "yes" : "no"; @@ -1969,18 +1974,16 @@ static int i915_context_status(struct seq_file *m, void *unused) static void i915_dump_lrc_obj(struct seq_file *m, struct intel_engine_cs *ring, - struct drm_i915_gem_object *ctx_obj) + struct drm_i915_gem_object *ctx_obj, + unsigned long dump_type) { struct page *page; + struct sg_page_iter sg_iter; uint32_t *reg_state; + int i; int j; unsigned long ggtt_offset = 0; - - if (ctx_obj == NULL) { - seq_printf(m, "Context on %s with no gem object\n", - ring->name); - return; - } + int hws_page_index; seq_printf(m, "CONTEXT: %s %u\n", ring->name, intel_execlists_ctx_id(ctx_obj)); @@ -1995,29 +1998,44 @@ static void i915_dump_lrc_obj(struct seq_file *m, return; } - page = i915_gem_object_get_page(ctx_obj, LRC_STATE_PN); - if (!WARN_ON(page == NULL)) { - reg_state = kmap_atomic(page); + i = 0; + hws_page_index = LRC_PPHWSP_PN; + for_each_sg_page(ctx_obj->pages->sgl, &sg_iter, + ctx_obj->pages->nents, 0) { + if (dump_type == LRC_CONTEXT_DUMP) { + if (i < hws_page_index) { + ++i; + continue; + } else if (i > hws_page_index) + break; + } - 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", - ggtt_offset + 4096 + (j * 4), - reg_state[j], reg_state[j + 1], - reg_state[j + 2], reg_state[j + 3]); + page = sg_page_iter_page(&sg_iter); + if (!WARN_ON(page == NULL)) { + reg_state = kmap_atomic(page); + + for (j = 0; j < PAGE_SIZE / sizeof(u32); j += 4) { + seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n", + ggtt_offset + 4096 + (j * 4), + reg_state[j], reg_state[j + 1], + reg_state[j + 2], reg_state[j + 3]); + } + kunmap_atomic(reg_state); } - kunmap_atomic(reg_state); + ++i; } seq_putc(m, '\n'); } -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; struct drm_device *dev = node->minor->dev; struct drm_i915_private *dev_priv = dev->dev_private; struct intel_engine_cs *ring; struct intel_context *ctx; + uintptr_t dump_type = (uintptr_t) node->info_ent->data; int ret, i; if (!i915.enable_execlists) { @@ -2031,9 +2049,21 @@ static int i915_dump_lrc(struct seq_file *m, void *unused) list_for_each_entry(ctx, &dev_priv->context_list, link) { for_each_ring(ring, dev_priv, i) { - if (ring->default_context != ctx) - i915_dump_lrc_obj(m, ring, - ctx->engine[i].state); + if (ring->default_context != ctx) { + struct drm_i915_gem_object *ctx_obj = + ctx->engine[i].state; + if (ctx_obj && ctx->file_priv) { + seq_printf(m, "CONTEXT: %s (PID: %u, UH:%d)\n", + ring->name, + pid_nr(ctx->file_priv->file->pid), + ctx->user_handle); + i915_dump_lrc_obj(m, ring, + ctx_obj, + dump_type); + } else + seq_printf(m, "Context on %s with no gem object\n", + ring->name); + } } } @@ -5189,7 +5219,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_dump_lrc", i915_dump_lrc, 0, (void *) LRC_CONTEXT_DUMP}, + {"i915_context_dump", 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},