From patchwork Mon Nov 7 22:27:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 9416175 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 E724360585 for ; Mon, 7 Nov 2016 22:27:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5E7C28E68 for ; Mon, 7 Nov 2016 22:27:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAC4C28E53; Mon, 7 Nov 2016 22:27:15 +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 3BB2828C33 for ; Mon, 7 Nov 2016 22:27:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A1EF36E2C7; Mon, 7 Nov 2016 22:27:14 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4A75C6E2C1 for ; Mon, 7 Nov 2016 22:27:10 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id u144so18961489wmu.0 for ; Mon, 07 Nov 2016 14:27:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=wYWdWiOkpymjwBJne0KYpVOTfmvPorC/vHsPlSby/dI=; b=dtoHeEh6hCgp5tRlcYjP7K+bPt5xy93Hwg7ynuZTJ3rPlMxjMkqdL6UocT3xTJ+Uy7 zaJtRsnGXgD1gMZ6yLmTC5DzQLqcoC/UQTMUlBhPCM7G4Bt+vRxuyfKtzXpaYEBGE5Vj d/yPRqWUE+Ni0PyQv+I+a8YlHJt21AnueFBL4SlZM+kszvkDpd2soh/cAvZaXSGRnbqI Wb5p1ffQCf5zSubGuxckm7uPHOCWkR67TD31OpiIr4Am2ajSPVWqke4/BCcg58MkZKO8 1wAFMEHGih/sGSGqjqiEceKzmrhqRNNs8f09w4apxyW0X0GZocpNPRXnmcIHHEuE0Wi9 0pgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=wYWdWiOkpymjwBJne0KYpVOTfmvPorC/vHsPlSby/dI=; b=FM1pwfJC0RDoJgGPxC+IFAGponmhySIJMNYJZI64mco458UJAQb13I3eI2moqKShkX 2JXcuWCGIdURVVlxmUaVpDxaYk9LDdnspQCrEyhTOilm9PhmtBbPZKwU/6OwBcBz6Wqw p9nqIJAVDPbdJO1LAECioQ1Zsjx4Um47IZPf62Cvel0h6P9m009xvuDDgbSTqgVVZIdA UBkHTRUuvrfeb4g51Lf4qXMuQeA/05w044F5IHn3thG9IRCaqwWPg3sWFnlEdsI2xuf3 rbKMnTQtuO0apYuh6MdHgoOlgJ85Jin+CpZB88mPqFr36WHowJXsJHLQlQ6fhCtmLTjE gvvw== X-Gm-Message-State: ABUngvc+5CS1+/7iByjzdiwl436h37Lg72StGCSAXdcrkDsge/86hqCPgVUtgymKXDMrrg== X-Received: by 10.28.169.4 with SMTP id s4mr9888039wme.65.1478557628751; Mon, 07 Nov 2016 14:27:08 -0800 (PST) Received: from sixbynine.org (cpc26-heme10-2-0-cust305.9-1.cable.virginm.net. [86.3.57.50]) by smtp.gmail.com with ESMTPSA id l6sm33503997wjc.7.2016.11.07.14.27.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Nov 2016 14:27:08 -0800 (PST) From: Robert Bragg To: intel-gfx@lists.freedesktop.org Date: Mon, 7 Nov 2016 22:27:00 +0000 Message-Id: <20161107222703.10784-4-robert@sixbynine.org> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161107222703.10784-1-robert@sixbynine.org> References: <20161107222703.10784-1-robert@sixbynine.org> Subject: [Intel-gfx] [PATCH igt v2 3/6] igt/gem_exec_parse: some minor cleanups 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 This normalizes the execbuf utilities in this file to all use memset to clear obj, reloc and execbuf structures and set them up in the same order. As I was debugging some unpredictable test failures I was getting unsure that all these structures were being fully initialized. The same I915_GEM_DOMAIN_COMMAND domain is now used with all relocs. The register/command defines have been moved to the top of the file to be available to all tests/utilities. The handle + fd variables are now static. Signed-off-by: Robert Bragg --- tests/gem_exec_parse.c | 196 +++++++++++++++++-------------------------------- 1 file changed, 66 insertions(+), 130 deletions(-) diff --git a/tests/gem_exec_parse.c b/tests/gem_exec_parse.c index 36bf57d..54760bc 100644 --- a/tests/gem_exec_parse.c +++ b/tests/gem_exec_parse.c @@ -36,6 +36,20 @@ #define DERRMR 0x44050 +#define HSW_CS_GPR(n) (0x2600 + 8*(n)) +#define HSW_CS_GPR0 HSW_CS_GPR(0) +#define HSW_CS_GPR1 HSW_CS_GPR(1) + +#define MI_LOAD_REGISTER_REG (0x2a << 23) +#define MI_STORE_REGISTER_MEM (0x24 << 23) +#define MI_ARB_ON_OFF (0x8 << 23) +#define MI_DISPLAY_FLIP ((0x14 << 23) | 1) + +#define GFX_OP_PIPE_CONTROL ((0x3<<29)|(0x3<<27)|(0x2<<24)|2) +#define PIPE_CONTROL_QW_WRITE (1<<14) +#define PIPE_CONTROL_LRI_POST_OP (1<<23) + + static int command_parser_version(int fd) { int version = -1; @@ -50,12 +64,6 @@ static int command_parser_version(int fd) return -1; } -#define HSW_CS_GPR(n) (0x2600 + 8*(n)) -#define HSW_CS_GPR0 HSW_CS_GPR(0) -#define HSW_CS_GPR1 HSW_CS_GPR(1) - -#define MI_LOAD_REGISTER_REG (0x2a << 23) -#define MI_STORE_REGISTER_MEM (0x24 << 23) static void hsw_load_register_reg(void) { uint32_t buf[16] = { @@ -99,13 +107,13 @@ static void hsw_load_register_reg(void) reloc[0].offset = 7*sizeof(uint32_t); reloc[0].target_handle = obj[0].handle; reloc[0].delta = 0; - reloc[0].read_domains = I915_GEM_DOMAIN_INSTRUCTION; - reloc[0].write_domain = I915_GEM_DOMAIN_INSTRUCTION; + reloc[0].read_domains = I915_GEM_DOMAIN_COMMAND; + reloc[0].write_domain = I915_GEM_DOMAIN_COMMAND; reloc[1].offset = 13*sizeof(uint32_t); reloc[1].target_handle = obj[0].handle; reloc[1].delta = sizeof(uint32_t); - reloc[1].read_domains = I915_GEM_DOMAIN_INSTRUCTION; - reloc[1].write_domain = I915_GEM_DOMAIN_INSTRUCTION; + reloc[1].read_domains = I915_GEM_DOMAIN_COMMAND; + reloc[1].write_domain = I915_GEM_DOMAIN_COMMAND; obj[1].relocs_ptr = (uintptr_t)&reloc; obj[1].relocation_count = 2; @@ -147,7 +155,7 @@ static void exec_batch_patched(int fd, uint32_t cmd_bo, uint32_t *cmds, int size, int patch_offset, uint64_t expected_value) { struct drm_i915_gem_execbuffer2 execbuf; - struct drm_i915_gem_exec_object2 objs[2]; + struct drm_i915_gem_exec_object2 obj[2]; struct drm_i915_gem_relocation_entry reloc[1]; uint32_t target_bo = gem_create(fd, 4096); @@ -155,42 +163,24 @@ static void exec_batch_patched(int fd, uint32_t cmd_bo, uint32_t *cmds, gem_write(fd, cmd_bo, 0, cmds, size); + memset(obj, 0, sizeof(obj)); + obj[0].handle = target_bo; + obj[1].handle = cmd_bo; + + memset(reloc, 0, sizeof(reloc)); reloc[0].offset = patch_offset; + reloc[0].target_handle = obj[0].handle; reloc[0].delta = 0; - reloc[0].target_handle = target_bo; - reloc[0].read_domains = I915_GEM_DOMAIN_RENDER; - reloc[0].write_domain = I915_GEM_DOMAIN_RENDER; - reloc[0].presumed_offset = 0; - - objs[0].handle = target_bo; - objs[0].relocation_count = 0; - objs[0].relocs_ptr = 0; - objs[0].alignment = 0; - objs[0].offset = 0; - objs[0].flags = 0; - objs[0].rsvd1 = 0; - objs[0].rsvd2 = 0; - - objs[1].handle = cmd_bo; - objs[1].relocation_count = 1; - objs[1].relocs_ptr = (uintptr_t)reloc; - objs[1].alignment = 0; - objs[1].offset = 0; - objs[1].flags = 0; - objs[1].rsvd1 = 0; - objs[1].rsvd2 = 0; - - execbuf.buffers_ptr = (uintptr_t)objs; + reloc[0].read_domains = I915_GEM_DOMAIN_COMMAND; + reloc[0].write_domain = I915_GEM_DOMAIN_COMMAND; + obj[1].relocs_ptr = (uintptr_t)reloc; + obj[1].relocation_count = 1; + + memset(&execbuf, 0, sizeof(execbuf)); + execbuf.buffers_ptr = (uintptr_t)obj; execbuf.buffer_count = 2; - execbuf.batch_start_offset = 0; execbuf.batch_len = size; - execbuf.cliprects_ptr = 0; - execbuf.num_cliprects = 0; - execbuf.DR1 = 0; - execbuf.DR4 = 0; execbuf.flags = I915_EXEC_RENDER; - i915_execbuffer2_set_context_id(execbuf, 0); - execbuf.rsvd2 = 0; gem_execbuf(fd, &execbuf); gem_sync(fd, cmd_bo); @@ -205,30 +195,18 @@ static int __exec_batch(int fd, uint32_t cmd_bo, uint32_t *cmds, int size, int ring) { struct drm_i915_gem_execbuffer2 execbuf; - struct drm_i915_gem_exec_object2 objs[1]; + struct drm_i915_gem_exec_object2 obj[1]; gem_write(fd, cmd_bo, 0, cmds, size); - objs[0].handle = cmd_bo; - objs[0].relocation_count = 0; - objs[0].relocs_ptr = 0; - objs[0].alignment = 0; - objs[0].offset = 0; - objs[0].flags = 0; - objs[0].rsvd1 = 0; - objs[0].rsvd2 = 0; + memset(obj, 0, sizeof(obj)); + obj[0].handle = cmd_bo; - execbuf.buffers_ptr = (uintptr_t)objs; + memset(&execbuf, 0, sizeof(execbuf)); + execbuf.buffers_ptr = (uintptr_t)obj; execbuf.buffer_count = 1; - execbuf.batch_start_offset = 0; execbuf.batch_len = size; - execbuf.cliprects_ptr = 0; - execbuf.num_cliprects = 0; - execbuf.DR1 = 0; - execbuf.DR4 = 0; execbuf.flags = ring; - i915_execbuffer2_set_context_id(execbuf, 0); - execbuf.rsvd2 = 0; return __gem_execbuf(fd, &execbuf); } @@ -239,7 +217,7 @@ static void exec_split_batch(int fd, uint32_t *cmds, int size, int ring, int expected_ret) { struct drm_i915_gem_execbuffer2 execbuf; - struct drm_i915_gem_exec_object2 objs[1]; + struct drm_i915_gem_exec_object2 obj[1]; uint32_t cmd_bo; uint32_t noop[1024] = { 0 }; const int alloc_size = 4096 * 2; @@ -256,16 +234,11 @@ static void exec_split_batch(int fd, uint32_t *cmds, */ gem_write(fd, cmd_bo, actual_start_offset, cmds, size); - objs[0].handle = cmd_bo; - objs[0].relocation_count = 0; - objs[0].relocs_ptr = 0; - objs[0].alignment = 0; - objs[0].offset = 0; - objs[0].flags = 0; - objs[0].rsvd1 = 0; - objs[0].rsvd2 = 0; + memset(obj, 0, sizeof(obj)); + obj[0].handle = cmd_bo; - execbuf.buffers_ptr = (uintptr_t)objs; + memset(&execbuf, 0, sizeof(execbuf)); + execbuf.buffers_ptr = (uintptr_t)obj; execbuf.buffer_count = 1; /* NB: We want batch_start_offset and batch_len to point to the block * of the actual commands (i.e. at the last dword of the first page), @@ -276,13 +249,7 @@ static void exec_split_batch(int fd, uint32_t *cmds, execbuf.batch_len = ALIGN(size + actual_start_offset - execbuf.batch_start_offset, 0x8); - execbuf.cliprects_ptr = 0; - execbuf.num_cliprects = 0; - execbuf.DR1 = 0; - execbuf.DR4 = 0; execbuf.flags = ring; - i915_execbuffer2_set_context_id(execbuf, 0); - execbuf.rsvd2 = 0; igt_assert_eq(__gem_execbuf(fd, &execbuf), expected_ret); @@ -295,8 +262,8 @@ static void exec_batch_chained(int fd, uint32_t cmd_bo, uint32_t *cmds, uint64_t expected_value) { struct drm_i915_gem_execbuffer2 execbuf; - struct drm_i915_gem_exec_object2 objs[3]; - struct drm_i915_gem_relocation_entry reloc; + struct drm_i915_gem_exec_object2 obj[3]; + struct drm_i915_gem_relocation_entry reloc[1]; struct drm_i915_gem_relocation_entry first_level_reloc; uint32_t target_bo = gem_create(fd, 4096); @@ -317,58 +284,34 @@ static void exec_batch_chained(int fd, uint32_t cmd_bo, uint32_t *cmds, first_level_cmds, sizeof(first_level_cmds)); gem_write(fd, cmd_bo, 0, cmds, size); - reloc.offset = patch_offset; - reloc.delta = 0; - reloc.target_handle = target_bo; - reloc.read_domains = I915_GEM_DOMAIN_RENDER; - reloc.write_domain = I915_GEM_DOMAIN_RENDER; - reloc.presumed_offset = 0; + memset(obj, 0, sizeof(obj)); + obj[0].handle = target_bo; + obj[1].handle = cmd_bo; + obj[2].handle = first_level_bo; + + memset(reloc, 0, sizeof(reloc)); + reloc[0].offset = patch_offset; + reloc[0].delta = 0; + reloc[0].target_handle = target_bo; + reloc[0].read_domains = I915_GEM_DOMAIN_COMMAND; + reloc[0].write_domain = I915_GEM_DOMAIN_COMMAND; + obj[1].relocation_count = 1; + obj[1].relocs_ptr = (uintptr_t)&reloc; + memset(&first_level_reloc, 0, sizeof(first_level_reloc)); first_level_reloc.offset = 4; first_level_reloc.delta = 0; first_level_reloc.target_handle = cmd_bo; - first_level_reloc.read_domains = I915_GEM_DOMAIN_INSTRUCTION; + first_level_reloc.read_domains = I915_GEM_DOMAIN_COMMAND; first_level_reloc.write_domain = 0; - first_level_reloc.presumed_offset = 0; - - objs[0].handle = target_bo; - objs[0].relocation_count = 0; - objs[0].relocs_ptr = 0; - objs[0].alignment = 0; - objs[0].offset = 0; - objs[0].flags = 0; - objs[0].rsvd1 = 0; - objs[0].rsvd2 = 0; - - objs[1].handle = cmd_bo; - objs[1].relocation_count = 1; - objs[1].relocs_ptr = (uintptr_t)&reloc; - objs[1].alignment = 0; - objs[1].offset = 0; - objs[1].flags = 0; - objs[1].rsvd1 = 0; - objs[1].rsvd2 = 0; - - objs[2].handle = first_level_bo; - objs[2].relocation_count = 1; - objs[2].relocs_ptr = (uintptr_t)&first_level_reloc; - objs[2].alignment = 0; - objs[2].offset = 0; - objs[2].flags = 0; - objs[2].rsvd1 = 0; - objs[2].rsvd2 = 0; - - execbuf.buffers_ptr = (uintptr_t)objs; + obj[2].relocation_count = 1; + obj[2].relocs_ptr = (uintptr_t)&first_level_reloc; + + memset(&execbuf, 0, sizeof(execbuf)); + execbuf.buffers_ptr = (uintptr_t)obj; execbuf.buffer_count = 3; - execbuf.batch_start_offset = 0; execbuf.batch_len = sizeof(first_level_cmds); - execbuf.cliprects_ptr = 0; - execbuf.num_cliprects = 0; - execbuf.DR1 = 0; - execbuf.DR4 = 0; execbuf.flags = I915_EXEC_RENDER; - i915_execbuffer2_set_context_id(execbuf, 0); - execbuf.rsvd2 = 0; gem_execbuf(fd, &execbuf); gem_sync(fd, cmd_bo); @@ -380,15 +323,8 @@ static void exec_batch_chained(int fd, uint32_t cmd_bo, uint32_t *cmds, gem_close(fd, target_bo); } -uint32_t handle; -int fd; - -#define MI_ARB_ON_OFF (0x8 << 23) -#define MI_DISPLAY_FLIP ((0x14 << 23) | 1) - -#define GFX_OP_PIPE_CONTROL ((0x3<<29)|(0x3<<27)|(0x2<<24)|2) -#define PIPE_CONTROL_QW_WRITE (1<<14) -#define PIPE_CONTROL_LRI_POST_OP (1<<23) +static uint32_t handle; +static int fd; igt_main {