From patchwork Tue Dec 1 20:38:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 11945035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF949C83012 for ; Wed, 2 Dec 2020 08:20:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9025322242 for ; Wed, 2 Dec 2020 08:20:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9025322242 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=v3.sk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 38B1C6EA3A; Wed, 2 Dec 2020 08:20:00 +0000 (UTC) Received: from shell.v3.sk (mail.v3.sk [167.172.186.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id 479756E02B; Tue, 1 Dec 2020 20:38:41 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id CF024E0718; Tue, 1 Dec 2020 20:35:43 +0000 (UTC) Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id UupzO_AEa56m; Tue, 1 Dec 2020 20:35:43 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 1E575DF932; Tue, 1 Dec 2020 20:35:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at zimbra.v3.sk Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id F16q-sWhVsli; Tue, 1 Dec 2020 20:35:42 +0000 (UTC) Received: from localhost (unknown [109.183.109.54]) by zimbra.v3.sk (Postfix) with ESMTPSA id B6EE5E0711; Tue, 1 Dec 2020 20:35:42 +0000 (UTC) From: Lubomir Rintel To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 1/3] tests/etnaviv_2d_test: explain the errors Date: Tue, 1 Dec 2020 21:38:27 +0100 Message-Id: <20201201203829.1735559-2-lkundrak@v3.sk> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201201203829.1735559-1-lkundrak@v3.sk> References: <20201201203829.1735559-1-lkundrak@v3.sk> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 02 Dec 2020 08:19:47 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lubomir Rintel , etnaviv@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Just so that it's obvious what failed and why. Signed-off-by: Lubomir Rintel Reviewed-by: Christian Gmeiner --- tests/etnaviv/etnaviv_2d_test.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/etnaviv/etnaviv_2d_test.c b/tests/etnaviv/etnaviv_2d_test.c index 8dd77b66..eb9dfa59 100644 --- a/tests/etnaviv/etnaviv_2d_test.c +++ b/tests/etnaviv/etnaviv_2d_test.c @@ -162,9 +162,16 @@ int main(int argc, char *argv[]) drmVersionPtr version; int fd, ret = 0; - fd = open(argv[1], O_RDWR); - if (fd < 0) + if (argc < 2) { + fprintf(stderr, "Usage: %s /dev/dri/\n", argv[0]); return 1; + } + + fd = open(argv[1], O_RDWR); + if (fd < 0) { + perror(argv[1]); + return 1; + } version = drmGetVersion(fd); if (version) { @@ -178,6 +185,7 @@ int main(int argc, char *argv[]) dev = etna_device_new(fd); if (!dev) { + perror("etna_device_new"); ret = 2; goto out; } @@ -185,18 +193,21 @@ int main(int argc, char *argv[]) /* TODO: we assume that core 0 is a 2D capable one */ gpu = etna_gpu_new(dev, 0); if (!gpu) { + perror("etna_gpu_new"); ret = 3; goto out_device; } pipe = etna_pipe_new(gpu, ETNA_PIPE_2D); if (!pipe) { + perror("etna_pipe_new"); ret = 4; goto out_gpu; } bmp = etna_bo_new(dev, bmp_size, ETNA_BO_UNCACHED); if (!bmp) { + perror("etna_bo_new"); ret = 5; goto out_pipe; } @@ -204,6 +215,7 @@ int main(int argc, char *argv[]) stream = etna_cmd_stream_new(pipe, 0x300, NULL, NULL); if (!stream) { + perror("etna_cmd_stream_new"); ret = 6; goto out_bo; } From patchwork Tue Dec 1 20:38:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 11945033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D16EC83018 for ; Wed, 2 Dec 2020 08:20:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E6F6D22240 for ; Wed, 2 Dec 2020 08:20:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E6F6D22240 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=v3.sk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0696F6EA40; Wed, 2 Dec 2020 08:20:01 +0000 (UTC) Received: from shell.v3.sk (mail.v3.sk [167.172.186.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id 485F36E8D0; Tue, 1 Dec 2020 20:38:41 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id EC822DF932; Tue, 1 Dec 2020 20:35:43 +0000 (UTC) Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 4CNo_ZZzL4rs; Tue, 1 Dec 2020 20:35:43 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 5F46EE0711; Tue, 1 Dec 2020 20:35:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at zimbra.v3.sk Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id xlA33XeSl3Kl; Tue, 1 Dec 2020 20:35:43 +0000 (UTC) Received: from localhost (unknown [109.183.109.54]) by zimbra.v3.sk (Postfix) with ESMTPSA id 2A0A4E0715; Tue, 1 Dec 2020 20:35:43 +0000 (UTC) From: Lubomir Rintel To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 2/3] tests/etnaviv_2d_test: pick the 2D core Date: Tue, 1 Dec 2020 21:38:28 +0100 Message-Id: <20201201203829.1735559-3-lkundrak@v3.sk> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201201203829.1735559-1-lkundrak@v3.sk> References: <20201201203829.1735559-1-lkundrak@v3.sk> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 02 Dec 2020 08:19:47 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lubomir Rintel , etnaviv@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Run the test on a core capable of 2D rendering instead of hardcoding to core zero. Signed-off-by: Lubomir Rintel Reviewed-by: Christian Gmeiner --- tests/etnaviv/etnaviv_2d_test.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/tests/etnaviv/etnaviv_2d_test.c b/tests/etnaviv/etnaviv_2d_test.c index eb9dfa59..a75a4a89 100644 --- a/tests/etnaviv/etnaviv_2d_test.c +++ b/tests/etnaviv/etnaviv_2d_test.c @@ -161,6 +161,8 @@ int main(int argc, char *argv[]) drmVersionPtr version; int fd, ret = 0; + uint64_t feat; + int core = 0; if (argc < 2) { fprintf(stderr, "Usage: %s /dev/dri/\n", argv[0]); @@ -190,13 +192,28 @@ int main(int argc, char *argv[]) goto out; } - /* TODO: we assume that core 0 is a 2D capable one */ - gpu = etna_gpu_new(dev, 0); - if (!gpu) { - perror("etna_gpu_new"); - ret = 3; - goto out_device; - } + do { + gpu = etna_gpu_new(dev, core); + if (!gpu) { + perror("etna_gpu_new"); + ret = 3; + goto out_device; + } + + if (etna_gpu_get_param(gpu, ETNA_GPU_FEATURES_0, &feat)) { + perror("etna_gpu_get_param"); + ret = 4; + goto out_device; + } + + if ((feat & (1 << 9)) == 0) { + /* GPU not 2D capable. */ + etna_gpu_del(gpu); + gpu = NULL; + } + + core++; + } while (!gpu); pipe = etna_pipe_new(gpu, ETNA_PIPE_2D); if (!pipe) { From patchwork Tue Dec 1 20:38:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 11945023 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31F9BC64E8A for ; Wed, 2 Dec 2020 08:20:44 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 55AB12222C for ; Wed, 2 Dec 2020 08:20:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55AB12222C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=v3.sk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EFD9E6EA2F; Wed, 2 Dec 2020 08:19:58 +0000 (UTC) Received: from shell.v3.sk (mail.v3.sk [167.172.186.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id 73B2B6E8D6; Tue, 1 Dec 2020 20:38:41 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 71A26E0711; Tue, 1 Dec 2020 20:35:44 +0000 (UTC) Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id tiPaO2CeI9fH; Tue, 1 Dec 2020 20:35:43 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id C0A36E0714; Tue, 1 Dec 2020 20:35:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at zimbra.v3.sk Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 4EAlXu_6aPnQ; Tue, 1 Dec 2020 20:35:43 +0000 (UTC) Received: from localhost (unknown [109.183.109.54]) by zimbra.v3.sk (Postfix) with ESMTPSA id 92344E0713; Tue, 1 Dec 2020 20:35:43 +0000 (UTC) From: Lubomir Rintel To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 3/3] tests/etnaviv_2d_test: check whether the rendering is correct Date: Tue, 1 Dec 2020 21:38:29 +0100 Message-Id: <20201201203829.1735559-4-lkundrak@v3.sk> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201201203829.1735559-1-lkundrak@v3.sk> References: <20201201203829.1735559-1-lkundrak@v3.sk> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 02 Dec 2020 08:19:47 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lubomir Rintel , etnaviv@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Instead of always dumping the rendered picture, check whether it matches the expectations. This makes more sense for automated testing. Retain the ability to dump the picture instead of checking it when a file name is given as an argument. This also removes use of a hardcoded file name in a world writable directory, which is an unsafe thing to do anyway. Signed-off-by: Lubomir Rintel Reviewed-by: Christian Gmeiner --- tests/etnaviv/etnaviv_2d_test.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/tests/etnaviv/etnaviv_2d_test.c b/tests/etnaviv/etnaviv_2d_test.c index a75a4a89..9fcdae18 100644 --- a/tests/etnaviv/etnaviv_2d_test.c +++ b/tests/etnaviv/etnaviv_2d_test.c @@ -147,6 +147,27 @@ static void gen_cmd_stream(struct etna_cmd_stream *stream, struct etna_bo *bmp, etna_set_state(stream, VIVS_GL_FLUSH_CACHE, VIVS_GL_FLUSH_CACHE_PE2D); } +int etna_check_image(uint32_t *p, int width, int height) +{ + int i; + uint32_t expected; + + for (i = 0; i < width * height; i++) { + if (i%8 < 4 && i%(width*8) < width*4 && i%width < 8*16 && i < width*8*16) + expected = 0xff40ff40; + else + expected = 0x00000000; + + if (p[i] != expected) { + fprintf(stderr, "Offset %d: expected: 0x%08x, got: 0x%08x\n", + i, expected, p[i]); + return -1; + } + } + + return 0; +} + int main(int argc, char *argv[]) { const int width = 256; @@ -165,7 +186,7 @@ int main(int argc, char *argv[]) int core = 0; if (argc < 2) { - fprintf(stderr, "Usage: %s /dev/dri/\n", argv[0]); + fprintf(stderr, "Usage: %s /dev/dri/ []\n", argv[0]); return 1; } @@ -242,7 +263,11 @@ int main(int argc, char *argv[]) etna_cmd_stream_finish(stream); - bmp_dump32(etna_bo_map(bmp), width, height, false, "/tmp/etna.bmp"); + if (argc > 2) + bmp_dump32(etna_bo_map(bmp), width, height, false, argv[2]); + + if (etna_check_image(etna_bo_map(bmp), width, height)) + ret = 7; etna_cmd_stream_del(stream);