From patchwork Tue Apr 23 01:11:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 2475091 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id C69FC3FD40 for ; Tue, 23 Apr 2013 01:09:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 73B50E5DB7 for ; Mon, 22 Apr 2013 18:09:01 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from shiva.localdomain (unknown [209.20.75.48]) by gabe.freedesktop.org (Postfix) with ESMTP id 4D106E5C6A for ; Mon, 22 Apr 2013 18:08:49 -0700 (PDT) Received: by shiva.localdomain (Postfix, from userid 1005) id 8085788659; Tue, 23 Apr 2013 01:08:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on shiva.chad-versace.us X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=unavailable version=3.3.2 Received: from lundgren.kumite (c-24-21-100-90.hsd1.or.comcast.net [24.21.100.90]) by shiva.localdomain (Postfix) with ESMTPSA id 8CB9688625; Tue, 23 Apr 2013 01:08:45 +0000 (UTC) From: Ben Widawsky To: intel-gfx@lists.freedesktop.org Date: Mon, 22 Apr 2013 18:11:11 -0700 Message-Id: <1366679472-7824-2-git-send-email-ben@bwidawsk.net> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1366679472-7824-1-git-send-email-ben@bwidawsk.net> References: <1366657257-5017-1-git-send-email-ben@bwidawsk.net> <1366679472-7824-1-git-send-email-ben@bwidawsk.net> Cc: Ben Widawsky Subject: [Intel-gfx] [PATCH 2/3] [v2] intel_error_decode: HEAD stuff X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Show the decoded HEAD value, as well as print the calculated head offset per ringbuffer. This will be superceded in the next commit, but that patch is way more complicated than this one (read: error prone), so I want this here. Example: ringbuffer (blitter ring) at 0x00044000; HEAD points to: 0x00044950 v2: Actually make it work for all rings. Signed-off-by: Ben Widawsky --- tools/intel_error_decode.c | 50 ++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/tools/intel_error_decode.c b/tools/intel_error_decode.c index f554d57..434c13a 100644 --- a/tools/intel_error_decode.c +++ b/tools/intel_error_decode.c @@ -55,6 +55,13 @@ #include "intel_gpu_tools.h" #include "instdone.h" +static uint32_t +print_head(unsigned int reg) +{ + printf(" head = 0x%08x, wraps = %d\n", reg & (0x7ffff<<2), reg >> 21); + return reg & (0x7ffff<<2); +} + static void print_instdone(uint32_t devid, unsigned int instdone, unsigned int instdone1) { @@ -273,6 +280,20 @@ print_fence(unsigned int devid, uint64_t fence) } } +#define MAX_RINGS 10 /* I really hope this never... */ +uint32_t head[MAX_RINGS]; +int head_ndx = 0; +int num_rings = -1; +static void print_batch(int is_batch, const char *ring_name, uint32_t gtt_offset) +{ + const char *buffer_type[2] = { "ringbuffer", "batchbuffer" }; + if (is_batch) { + printf("%s (%s) at 0x%08x\n", buffer_type[is_batch], ring_name, gtt_offset); + } else { + printf("%s (%s) at 0x%08x; HEAD points to: 0x%08x\n", buffer_type[is_batch], ring_name, gtt_offset, head[head_ndx++ % num_rings] + gtt_offset); + } +} + static void read_data_file(FILE *file) { @@ -285,7 +306,6 @@ read_data_file(FILE *file) size_t line_size; uint32_t offset, value; uint32_t gtt_offset = 0, new_gtt_offset; - const char *buffer_type[2] = { "ringbuffer", "batchbuffer" }; char *ring_name = NULL; int is_batch = 1; @@ -299,14 +319,14 @@ read_data_file(FILE *file) strncpy(new_ring_name, line, dashes - line); new_ring_name[dashes - line - 1] = '\0'; + if (num_rings == -1) + num_rings = head_ndx; + matched = sscanf(dashes, "--- gtt_offset = 0x%08x\n", &new_gtt_offset); if (matched == 1) { if (count) { - printf("%s (%s) at 0x%08x:\n", - buffer_type[is_batch], - ring_name, - gtt_offset); + print_batch(is_batch, ring_name, gtt_offset); drm_intel_decode_set_batch_pointer(decode_ctx, data, gtt_offset, count); @@ -324,10 +344,7 @@ read_data_file(FILE *file) &new_gtt_offset); if (matched == 1) { if (count) { - printf("%s (%s) at 0x%08x:\n", - buffer_type[is_batch], - ring_name, - gtt_offset); + print_batch(is_batch, ring_name, gtt_offset); drm_intel_decode_set_batch_pointer(decode_ctx, data, gtt_offset, count); @@ -348,10 +365,7 @@ read_data_file(FILE *file) /* display reg section is after the ringbuffers, don't mix them */ if (count) { - printf("%s (%s) at 0x%08x:\n", - buffer_type[is_batch], - ring_name, - gtt_offset); + print_batch(is_batch, ring_name, gtt_offset); drm_intel_decode_set_batch_pointer(decode_ctx, data, gtt_offset, count); @@ -377,6 +391,11 @@ read_data_file(FILE *file) decode_ctx = drm_intel_decode_context_alloc(devid); } + matched = sscanf(line, " HEAD: 0x%08x\n", ®); + if (matched == 1) { + head[head_ndx++] = print_head(reg); + } + matched = sscanf(line, " ACTHD: 0x%08x\n", ®); if (matched == 1) drm_intel_decode_set_head_tail(decode_ctx, reg, 0xffffffff); @@ -415,10 +434,7 @@ read_data_file(FILE *file) } if (count) { - printf("%s (%s) at 0x%08x:\n", - buffer_type[is_batch], - ring_name, - gtt_offset); + print_batch(is_batch, ring_name, gtt_offset); drm_intel_decode_set_batch_pointer(decode_ctx, data, gtt_offset, count);