From patchwork Thu Nov 24 13:47:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 9445511 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 E543C606DB for ; Thu, 24 Nov 2016 13:47:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C935A27F8F for ; Thu, 24 Nov 2016 13:47:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD3B827F9C; Thu, 24 Nov 2016 13:47:52 +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 D64DB27F8F for ; Thu, 24 Nov 2016 13:47:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4914A6EA72; Thu, 24 Nov 2016 13:47:51 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wj0-x242.google.com (mail-wj0-x242.google.com [IPv6:2a00:1450:400c:c01::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 949EC6EA72 for ; Thu, 24 Nov 2016 13:47:49 +0000 (UTC) Received: by mail-wj0-x242.google.com with SMTP id xy5so3301230wjc.1 for ; Thu, 24 Nov 2016 05:47:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=ZnJK/uVmdjRxjdZ24V0ThCXODGMaq0GtK0f+M2dZdzo=; b=r91k0X+TTqWmxWxScM4u9TLiTyn+f2aJbh+9lhKmkNF00Kx4Qg5dE9TcaCAGi35o/g Kdvq5Fz8yFg+MJ+yDThpZ8i+4k7cx4YAvgPXMUyk+arjBN4gD5e9H8ZZadSTV1zJCmDo ey1i5tE5fQ6qz93BMhJSgQbKAJt2/aNXS3RJsuZSxw8J8N3LgTYOcKEWvs8EVEOrc+RV 0HWSYGfVNb0pOAvJpwRmmQSqZlRvXOyDZVNVK0ejL/4e21sO7Sw12mNSj94FvlzcQrBH J4I7Xb/Nb+zIL1v/9VKzjYgzSgnExcVonrA9SKmbtG7jraq+WrjB5ouMhFm3qVWQ12nX N9zw== 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:subject:date:message-id :in-reply-to:references; bh=ZnJK/uVmdjRxjdZ24V0ThCXODGMaq0GtK0f+M2dZdzo=; b=grh/6/y32cw+vTuSZUCVDKt29ZFSz/xp5eWrDAyFJq2zAnh1+QkI+2exgmpIkcRsUz P/d+JXa1FHcuieARP6EZ/hbswH1lx8+sH1YUBrhlqIPVGp+GJAzkRzbAKDNX4Kh5DLHI Uk0SNnk6PQTIGTqHKO9cjL8a6WJmcboJHYiGkzCod80WIycPqWOZHo4ZNbnGR3Cye8nF SRCCcCgklnetCX0yVsii8Qfd7YlqWsKsnT5gIE6lJUcnnRVRGvlQSSINUujfAiq2elWZ h8lNM2tTlfWuk/Wirt7z+PZDWLANsFFfUdkIt7hStIVviZNrOzb+4TDeHUDWOKmlEs7r yoCQ== X-Gm-Message-State: AKaTC01EeYkcEBqM01imc6VXePCeX0AW9fHUA/vKO8tBWJIaDu1ZCHbinmlWrvnGIBWwfA== X-Received: by 10.194.191.161 with SMTP id gz1mr2426164wjc.22.1479995267842; Thu, 24 Nov 2016 05:47:47 -0800 (PST) Received: from sixbynine.org (host-78-151-22-196.as13285.net. [78.151.22.196]) by smtp.gmail.com with ESMTPSA id di9sm41911522wjc.37.2016.11.24.05.47.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Nov 2016 05:47:47 -0800 (PST) From: Robert Bragg To: intel-gfx@lists.freedesktop.org Date: Thu, 24 Nov 2016 13:47:46 +0000 Message-Id: <20161124134746.30499-1-robert@sixbynine.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161122170328.GA8771@nuc-i3427.alporthouse.com> References: <20161122170328.GA8771@nuc-i3427.alporthouse.com> Subject: [Intel-gfx] [PATCH igt] igt/gem_exec_parse: generalise test_lri + debug info 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 further generalises the description passed to test_lri so we only need one loop over the entries with test_lri deducing the exected errno and value based on whether the register is marked as whitelisted and depending on the current command parser version. Each tested register LRI now test gets its own subtest like: igt_subtest_f("test-lri-%s", reg_name) The test_lri helper now also double checks that the initial intel_register_write() takes before issuing the LRI. In case of a failure the test_lri helper now uses igt_debug to log the register name, address and value being tested. Signed-off-by: Robert Bragg Cc: Chris Wilson Reviewed-by: Chris Wilson --- tests/gem_exec_parse.c | 102 +++++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/tests/gem_exec_parse.c b/tests/gem_exec_parse.c index cc2103a..0cd7053 100644 --- a/tests/gem_exec_parse.c +++ b/tests/gem_exec_parse.c @@ -258,12 +258,17 @@ static void exec_batch_chained(int fd, uint32_t cmd_bo, uint32_t *cmds, * from... */ struct test_lri { - uint32_t reg, read_mask, init_val, test_val; + const char *name; /* register name for debug info */ + uint32_t reg; /* address to test */ + uint32_t read_mask; /* ignore things like HW status bits */ + uint32_t init_val; /* initial identifiable value to set without LRI */ + uint32_t test_val; /* value to attempt loading via LRI command */ + bool whitelisted; /* expect to become NOOP / fail if not whitelisted */ + int min_ver; /* required command parser version to test */ }; static void -test_lri(int fd, uint32_t handle, - struct test_lri *test, int expected_errno, uint32_t expect) +test_lri(int fd, uint32_t handle, struct test_lri *test) { uint32_t lri[] = { MI_LOAD_REGISTER_IMM, @@ -271,9 +276,20 @@ test_lri(int fd, uint32_t handle, test->test_val, MI_BATCH_BUFFER_END, }; + int bad_lri_errno = parser_version >= 8 ? 0 : -EINVAL; + int expected_errno = test->whitelisted ? 0 : bad_lri_errno; + uint32_t expect = test->whitelisted ? test->test_val : test->init_val; + + igt_debug("Testing %s LRI: addr=%x, val=%x, expected errno=%d, expected val=%x\n", + test->name, test->reg, test->test_val, + expected_errno, expect); intel_register_write(test->reg, test->init_val); + igt_assert_eq_u32((intel_register_read(test->reg) & + test->read_mask), + test->init_val); + exec_batch(fd, handle, lri, sizeof(lri), I915_EXEC_RENDER, @@ -476,57 +492,43 @@ igt_main } igt_subtest_group { +#define REG(R, MSK, INI, V, OK, MIN_V) { #R, R, MSK, INI, V, OK, MIN_V } + struct test_lri lris[] = { + /* dummy head pointer */ + REG(OASTATUS2, + 0xffffff80, 0xdeadf000, 0xbeeff000, false, 0), + /* NB: [1:0] MBZ */ + REG(SO_WRITE_OFFSET_0, + 0xfffffffc, 0xabcdabc0, 0xbeefbee0, true, 0), + + /* It's really important for us to check that + * an LRI to OACONTROL doesn't result in an + * EINVAL error because Mesa attempts writing + * to OACONTROL to determine what extensions to + * expose and will abort() for execbuffer() + * errors. + * + * Mesa can gracefully recognise and handle the + * LRI becoming a NOOP. + * + * The test values represent dummy context IDs + * while leaving the OA unit disabled + */ + REG(OACONTROL, + 0xfffff000, 0xfeed0000, 0x31337000, false, 9) + }; +#undef REG + igt_fixture { intel_register_access_init(intel_get_pci_device(), 0); } - igt_subtest("registers") { - struct test_lri bad_lris[] = { - /* dummy head pointer */ - { OASTATUS2, 0xffffff80, 0xdeadf000, 0xbeeff000 } - }; - struct test_lri v9_bad_lris[] = { - /* It's really important for us to check that - * an LRI to OACONTROL doesn't result in an - * EINVAL error because Mesa attempts writing - * to OACONTROL to determine what extensions to - * expose and will abort() for execbuffer() - * errors. - * - * Mesa can gracefully recognise and handle the - * LRI becoming a NOOP. - * - * The test values represent dummy context IDs - * while leaving the OA unit disabled - */ - { OACONTROL, 0xfffff000, 0xfeed0000, 0x31337000 } - }; - struct test_lri ok_lris[] = { - /* NB: [1:0] MBZ */ - { SO_WRITE_OFFSET_0, 0xfffffffc, - 0xabcdabc0, 0xbeefbee0 } - }; - int bad_lri_errno = parser_version >= 8 ? 0 : -EINVAL; - - for (int i = 0; i < ARRAY_SIZE(ok_lris); i++) { - test_lri(fd, handle, - ok_lris + i, 0, - ok_lris[i].test_val); - } - - for (int i = 0; i < ARRAY_SIZE(bad_lris); i++) { - test_lri(fd, handle, - bad_lris + i, bad_lri_errno, - bad_lris[i].init_val); - } - - if (parser_version >= 9) { - for (int i = 0; i < ARRAY_SIZE(v9_bad_lris); i++) { - test_lri(fd, handle, - v9_bad_lris + i, - 0, - v9_bad_lris[i].init_val); - } + for (int i = 0; i < ARRAY_SIZE(lris); i++) { + igt_subtest_f("test-lri-%s", lris[i].name) { + igt_require_f(parser_version >= lris[i].min_ver, + "minimum required parser version for test = %d\n", + lris[i].min_ver); + test_lri(fd, handle, lris + i); } }