From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eugeni Dodonov Subject: [PATCH 4/6] intel_gpu_top: initialize monitoring statistics at startup Date: Mon, 5 Sep 2011 17:19:31 -0300 Message-ID: <1315253973-18950-5-git-send-email-eugeni@dodonov.net> References: <1315253973-18950-1-git-send-email-eugeni@dodonov.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from oproxy9.bluehost.com (oproxy9.bluehost.com [69.89.24.6]) by gabe.freedesktop.org (Postfix) with SMTP id 735CEA090E for ; Mon, 5 Sep 2011 13:20:36 -0700 (PDT) In-Reply-To: <1315253973-18950-1-git-send-email-eugeni@dodonov.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: intel-gfx@lists.freedesktop.org Cc: Eugeni Dodonov List-Id: intel-gfx@lists.freedesktop.org From: Eugeni Dodonov This patch initializes the last_stats[] for registers prior to starting the monitoring itself. This way, the first measure will already contain the difference from the previous value instead of non-initialized value. Signed-off-by: Eugeni Dodonov --- tools/intel_gpu_top.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index edb4a82..e2dd173 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -475,6 +475,22 @@ int main(int argc, char **argv) ring_init(&blt_ring); } + /* Initialize GPU stats */ + if (HAS_STATS_REGS(devid)) { + for (i = 0; i < STATS_COUNT; i++) { + uint32_t stats_high, stats_low, stats_high_2; + + do { + stats_high = INREG(stats_regs[i] + 4); + stats_low = INREG(stats_regs[i]); + stats_high_2 = INREG(stats_regs[i] + 4); + } while (stats_high != stats_high_2); + + last_stats[i] = (uint64_t)stats_high << 32 | + stats_low; + } + } + for (;;) { int j; unsigned long long t1, ti, tf; -- 1.7.6.1