From patchwork Wed Aug 23 17:14:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Ekstrand X-Patchwork-Id: 9917941 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CB6EF603FA for ; Wed, 23 Aug 2017 17:15:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0762287B1 for ; Wed, 23 Aug 2017 17:15:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3C5C28845; Wed, 23 Aug 2017 17:15:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 34093287B1 for ; Wed, 23 Aug 2017 17:15:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C25F36E5E2; Wed, 23 Aug 2017 17:15:00 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pf0-x244.google.com (mail-pf0-x244.google.com [IPv6:2607:f8b0:400e:c00::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 20EBA6E5E2 for ; Wed, 23 Aug 2017 17:14:57 +0000 (UTC) Received: by mail-pf0-x244.google.com with SMTP id m89so82524pfk.5 for ; Wed, 23 Aug 2017 10:14:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jlekstrand-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vp12lqNRttKue9uan1sv5OVs4T08Tx2DM1ur9rQm9Os=; b=hJWoKef89zrFrcp6NxQnoc3I+GlTX5dTA1qn9TIE48UEz7C1s/p1yKQKhcULCOQJKu JyphPFZBKA+bf3NS7WM9O2BEFJ5AkYQZ8FxrKoF71OgL4iXbwnA2nllIX99pGrERlHgw wnNZ9KLYCnbACDI7zxfcCEhQZ8G1ShPaYxRwxFljQbGJICwsHEvmORts+66QWtkLw5pa 18yjJnQRG15JFa7EmCTzPqju2oIaQpDNwYQYD26TlgS5JxkM1RWdtTtgFjNKlMAdOnLh NJWU4VGp69kJ35b5cC18pAywM3umGiwPL5qERDi1QITIk+OJ+i5Jo5XnySuM5Vo83W2L M38w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vp12lqNRttKue9uan1sv5OVs4T08Tx2DM1ur9rQm9Os=; b=YTBiTDpLbcGA8/YTw6Nq8GC9en71n3MMmpVVksEJuOqw9oBpwVuE1nBwNhHXDuk9+S +nykgs1q7sar6AUCB4CXbqMtcvqmRV+qRSPgJNVFO3zgxCzYfmIXoOgmcWbNHq3l2oaJ 8QwiejwUloUNdIoRkRbAmd/mB47sUYWYmkwcsWiG0G0N+QetRs3D47Cuu6Ydm2PYt4Mz AmJpdmqktWcpAZwoAhJp1+kToQ9xyiaBQHZWpYJxzDNIB+gp91Rr/BOMEEX2ecM+QV/z Ljhk61Q+Y3rZne5Gy8wLhewoPat5UdcqZ7TGdbawBGLEdy5gkjmUxW8FH2pl+jCGoJG1 kurQ== X-Gm-Message-State: AHYfb5jWVx5XtNA2hfiAmrX6YnO4z/9XUR5SW2pVs7aNGZjsoPJ46fEp m2rvHYfhtO3FgnshI4H8dA== X-Received: by 10.99.0.69 with SMTP id 66mr3352716pga.21.1503508497097; Wed, 23 Aug 2017 10:14:57 -0700 (PDT) Received: from omlet.jf.intel.com (fmdmzpr01-ext.fm.intel.com. [192.55.54.36]) by smtp.gmail.com with ESMTPSA id v12sm5297185pgf.6.2017.08.23.10.14.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Aug 2017 10:14:56 -0700 (PDT) From: Jason Ekstrand X-Google-Original-From: Jason Ekstrand To: intel-gfx@lists.freedesktop.org Date: Wed, 23 Aug 2017 10:14:45 -0700 Message-Id: <1503508486-19432-3-git-send-email-jason.ekstrand@intel.com> X-Mailer: git-send-email 2.5.0.400.gff86faf In-Reply-To: <1503508486-19432-1-git-send-email-jason.ekstrand@intel.com> References: <1503508486-19432-1-git-send-email-jason.ekstrand@intel.com> Cc: Jason Ekstrand Subject: [Intel-gfx] [PATCH i-g-t 2/3] aubdump: Use write_reloc for filling out the ringbuffer 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-Virus-Scanned: ClamAV using ClamSMTP --- tools/aubdump.c | 66 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 34 deletions(-) Reviewed-by: Lionel Landwerlin diff --git a/tools/aubdump.c b/tools/aubdump.c index c14c9fa..567de3d 100644 --- a/tools/aubdump.c +++ b/tools/aubdump.c @@ -262,9 +262,36 @@ aub_write_trace_block(uint32_t type, void *virtual, uint32_t size, uint64_t gtt_ } static void +write_reloc(void *p, uint64_t v) +{ + if (gen >= 8) { + /* From the Broadwell PRM Vol. 2a, + * MI_LOAD_REGISTER_MEM::MemoryAddress: + * + * "This field specifies the address of the memory + * location where the register value specified in the + * DWord above will read from. The address specifies + * the DWord location of the data. Range = + * GraphicsVirtualAddress[63:2] for a DWord register + * GraphicsAddress [63:48] are ignored by the HW and + * assumed to be in correct canonical form [63:48] == + * [47]." + * + * In practice, this will always mean the top bits are zero + * because of the GTT size limitation of the aubdump tool. + */ + const int shift = 63 - 47; + *(uint64_t *)p = (((int64_t)v) << shift) >> shift; + } else { + *(uint32_t *)p = v; + } +} + +static void aub_dump_ringbuffer(uint64_t batch_offset, uint64_t offset, int ring_flag) { uint32_t ringbuffer[4096]; + unsigned aub_mi_bbs_len; int ring = AUB_TRACE_TYPE_RING_PRB0; /* The default ring */ int ring_count = 0; @@ -275,14 +302,11 @@ aub_dump_ringbuffer(uint64_t batch_offset, uint64_t offset, int ring_flag) /* Make a ring buffer to execute our batchbuffer. */ memset(ringbuffer, 0, sizeof(ringbuffer)); - if (gen >= 8) { - ringbuffer[ring_count++] = AUB_MI_BATCH_BUFFER_START | (3 - 2); - ringbuffer[ring_count++] = batch_offset; - ringbuffer[ring_count++] = batch_offset >> 32; - } else { - ringbuffer[ring_count++] = AUB_MI_BATCH_BUFFER_START; - ringbuffer[ring_count++] = batch_offset; - } + + aub_mi_bbs_len = gen >= 8 ? 3 : 2; + ringbuffer[ring_count] = AUB_MI_BATCH_BUFFER_START | (aub_mi_bbs_len - 2); + write_reloc(&ringbuffer[ring_count + 1], batch_offset); + ring_count += aub_mi_bbs_len; /* Write out the ring. This appears to trigger execution of * the ring in the simulator. @@ -299,32 +323,6 @@ aub_dump_ringbuffer(uint64_t batch_offset, uint64_t offset, int ring_flag) data_out(ringbuffer, ring_count * 4); } -static void -write_reloc(void *p, uint64_t v) -{ - if (gen >= 8) { - /* From the Broadwell PRM Vol. 2a, - * MI_LOAD_REGISTER_MEM::MemoryAddress: - * - * "This field specifies the address of the memory - * location where the register value specified in the - * DWord above will read from. The address specifies - * the DWord location of the data. Range = - * GraphicsVirtualAddress[63:2] for a DWord register - * GraphicsAddress [63:48] are ignored by the HW and - * assumed to be in correct canonical form [63:48] == - * [47]." - * - * In practice, this will always mean the top bits are zero - * because of the GTT size limitation of the aubdump tool. - */ - const int shift = 63 - 47; - *(uint64_t *)p = (((int64_t)v) << shift) >> shift; - } else { - *(uint32_t *)p = v; - } -} - static void * relocate_bo(struct bo *bo, const struct drm_i915_gem_execbuffer2 *execbuffer2, const struct drm_i915_gem_exec_object2 *obj)