From patchwork Wed Mar 27 05:06:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kenneth Graunke X-Patchwork-Id: 2347691 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 3CF213FD40 for ; Wed, 27 Mar 2013 06:27:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 77703E5CE5 for ; Tue, 26 Mar 2013 23:27:48 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from homiemail-a1.g.dreamhost.com (caiajhbdcbhh.dreamhost.com [208.97.132.177]) by gabe.freedesktop.org (Postfix) with ESMTP id 70E1EE5C8A for ; Tue, 26 Mar 2013 22:06:02 -0700 (PDT) Received: from homiemail-a1.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a1.g.dreamhost.com (Postfix) with ESMTP id 36D8D34806B; Tue, 26 Mar 2013 22:06:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=whitecape.org; h=from:to :cc:subject:date:message-id:in-reply-to:references; s= whitecape.org; bh=qhs3hXMCM+1gP0CsipYCO+nP8NY=; b=jXTKb9Lu2/4IYb CZdGKCyKaYtUtJhxT0AEAnXnu0qtf2vMGzKYHNvzTFEJ05y/8ESUHIDuQp02l/Bb 9pB6Knh8vjGBsYUF1Zao7JVXjOX8/B8BuxLwGHc9Ol0ijH33ancfqFv4jH10YIdc vMq47KssfDyMp3FEkSjfLyi5GjaYE= Received: from localhost.localdomain (static-50-43-15-186.bvtn.or.frontiernet.net [50.43.15.186]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: kenneth@whitecape.org) by homiemail-a1.g.dreamhost.com (Postfix) with ESMTPSA id C5B36348062; Tue, 26 Mar 2013 22:06:01 -0700 (PDT) From: Kenneth Graunke To: intel-gfx@lists.freedesktop.org Date: Tue, 26 Mar 2013 22:06:38 -0700 Message-Id: <1364360799-12064-2-git-send-email-kenneth@whitecape.org> X-Mailer: git-send-email 1.8.2 In-Reply-To: <1364360799-12064-1-git-send-email-kenneth@whitecape.org> References: <1364360799-12064-1-git-send-email-kenneth@whitecape.org> Subject: [Intel-gfx] [PATCH 2/3] intel_perf_counters: Abstract out Ironlake-specific code. 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 We want to support this tool on more platforms. This lays the groundwork for making that possible. Signed-off-by: Kenneth Graunke --- tools/intel_perf_counters.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/tools/intel_perf_counters.c b/tools/intel_perf_counters.c index 53d2ad7..fd268b1 100644 --- a/tools/intel_perf_counters.c +++ b/tools/intel_perf_counters.c @@ -37,9 +37,9 @@ #include "intel_bufmgr.h" #include "intel_batchbuffer.h" -#define COUNTER_COUNT 29 +#define GEN5_COUNTER_COUNT 29 -const char *counter_name[COUNTER_COUNT] = { +const char *gen5_counter_names[GEN5_COUNTER_COUNT] = { "cycles the CS unit is starved", "cycles the CS unit is stalled", "cycles the VF unit is starved", @@ -72,13 +72,13 @@ const char *counter_name[COUNTER_COUNT] = { }; int have_totals = 0; -uint32_t totals[COUNTER_COUNT]; -uint32_t last_counter[COUNTER_COUNT]; +uint32_t *totals; +uint32_t *last_counter; static drm_intel_bufmgr *bufmgr; struct intel_batchbuffer *batch; /* DW0 */ -#define MI_REPORT_PERF_COUNT ((0x26 << 23) | (3 - 2)) +#define GEN5_MI_REPORT_PERF_COUNT ((0x26 << 23) | (3 - 2)) #define MI_COUNTER_SET_0 (0 << 6) #define MI_COUNTER_SET_1 (1 << 6) /* DW1 */ @@ -86,7 +86,7 @@ struct intel_batchbuffer *batch; /* DW2: report ID */ static void -get_counters(void) +gen5_get_counters(void) { int i; drm_intel_bo *stats_bo; @@ -95,13 +95,13 @@ get_counters(void) stats_bo = drm_intel_bo_alloc(bufmgr, "stats", 4096, 4096); BEGIN_BATCH(6); - OUT_BATCH(MI_REPORT_PERF_COUNT | MI_COUNTER_SET_0); + OUT_BATCH(GEN5_MI_REPORT_PERF_COUNT | MI_COUNTER_SET_0); OUT_RELOC(stats_bo, I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, 0); OUT_BATCH(0); - OUT_BATCH(MI_REPORT_PERF_COUNT | MI_COUNTER_SET_1); + OUT_BATCH(GEN5_MI_REPORT_PERF_COUNT | MI_COUNTER_SET_1); OUT_RELOC(stats_bo, I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, 64); @@ -115,7 +115,7 @@ get_counters(void) stats_result = stats_bo->virtual; /* skip REPORT_ID, TIMESTAMP */ stats_result += 3; - for (i = 0 ; i < COUNTER_COUNT; i++) { + for (i = 0 ; i < GEN5_COUNTER_COUNT; i++) { totals[i] += stats_result[i] - last_counter[i]; last_counter[i] = stats_result[i]; } @@ -131,6 +131,9 @@ int main(int argc, char **argv) { uint32_t devid; + int counter_count; + const char **counter_name; + void (*get_counters)(void); int i; char clear_screen[] = {0x1b, '[', 'H', 0x1b, '[', 'J', @@ -145,10 +148,16 @@ main(int argc, char **argv) drm_intel_bufmgr_gem_enable_reuse(bufmgr); batch = intel_batchbuffer_alloc(bufmgr, devid); - if (!IS_GEN5(devid)) { - printf("This tool is only for Ironlake.\n"); + if (IS_GEN5(devid)) { + counter_name = gen5_counter_names; + counter_count = GEN5_COUNTER_COUNT; + get_counters = gen5_get_counters; + } else { + printf("This tool is not yet supported on your platform.\n"); abort(); } + totals = calloc(counter_count, sizeof(uint32_t)); + last_counter = calloc(counter_count, sizeof(uint32_t)); for (;;) { for (l = 0; l < STATS_CHECK_FREQUENCY; l++) { @@ -156,7 +165,7 @@ main(int argc, char **argv) if (l % (STATS_CHECK_FREQUENCY / STATS_REPORT_FREQUENCY) == 0) { if (have_totals) { - for (i = 0; i < COUNTER_COUNT; i++) { + for (i = 0; i < counter_count; i++) { printf("%s: %u\n", counter_name[i], totals[i]); totals[i] = 0; @@ -171,5 +180,8 @@ main(int argc, char **argv) } } + free(totals); + free(last_counter); + return 0; }