From patchwork Thu Oct 23 15:34:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Reese, Armin C" X-Patchwork-Id: 5141481 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2636BC11AD for ; Thu, 23 Oct 2014 15:36:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 24CDE20256 for ; Thu, 23 Oct 2014 15:36:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id AE21F20251 for ; Thu, 23 Oct 2014 15:36:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BD1066E4B1; Thu, 23 Oct 2014 08:36:37 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id 9DE286E4AC for ; Thu, 23 Oct 2014 08:36:36 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 23 Oct 2014 08:35:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,775,1406617200"; d="scan'208";a="594636018" Received: from acreese-hsw.fm.intel.com ([10.19.123.40]) by orsmga001.jf.intel.com with ESMTP; 23 Oct 2014 08:36:36 -0700 From: armin.c.reese@intel.com To: intel-gfx@lists.freedesktop.org Date: Thu, 23 Oct 2014 08:34:30 -0700 Message-Id: <1414078470-25647-4-git-send-email-armin.c.reese@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1414078470-25647-1-git-send-email-armin.c.reese@intel.com> References: <1414078470-25647-1-git-send-email-armin.c.reese@intel.com> Subject: [Intel-gfx] [PATCH 4/4] drm/i915: Add debugfs file to dump entire logical context X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 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 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 --- drivers/gpu/drm/i915/i915_debugfs.c | 64 +++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index e60d5c2..488a7d7 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 { + NO_CONTEXT_DUMP, + CONTEXT_DUMP, +}; + static const char *yesno(int v) { return v ? "yes" : "no"; @@ -120,6 +125,51 @@ 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; @@ -1708,9 +1758,10 @@ static void describe_ctx_ringbuf(struct seq_file *m, ringbuf->last_retired_head); } -static int i915_context_status(struct seq_file *m, void *unused) +static int i915_context_status(struct seq_file *m, void *data) { struct drm_info_node *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; @@ -1757,8 +1808,16 @@ static int i915_context_status(struct seq_file *m, void *unused) seq_printf(m, "%s: ", ring->name); if (ctx_obj) describe_obj(m, ctx_obj); + if (ringbuf) describe_ctx_ringbuf(m, ringbuf); + + if (ctx_obj && + (dump_flag == CONTEXT_DUMP)) { + seq_puts(m, "\nContext Dump:\n"); + dump_32_obj(m, ctx_obj); + } + seq_putc(m, '\n'); } } else { @@ -4184,7 +4243,8 @@ static const struct drm_info_list i915_debugfs_list[] = { {"i915_sr_status", i915_sr_status, 0}, {"i915_opregion", i915_opregion, 0}, {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0}, - {"i915_context_status", i915_context_status, 0}, + {"i915_context_status", i915_context_status, 0, (void *)NO_CONTEXT_DUMP}, + {"i915_context_dump", i915_context_status, 0, (void *)CONTEXT_DUMP}, {"i915_dump_lrc", i915_dump_lrc, 0}, {"i915_execlists", i915_execlists, 0}, {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info, 0},