From patchwork Tue Aug 31 16:17:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 504672 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 24E31C4320A for ; Tue, 31 Aug 2021 16:12:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 09B3F61057 for ; Tue, 31 Aug 2021 16:12:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239789AbhHaQNr (ORCPT ); Tue, 31 Aug 2021 12:13:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239795AbhHaQNq (ORCPT ); Tue, 31 Aug 2021 12:13:46 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4103C061575 for ; Tue, 31 Aug 2021 09:12:50 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id j1so12167606pjv.3 for ; Tue, 31 Aug 2021 09:12:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IzUUD53TRCina4FvQp5wgcW+VoUOyAwWBEy3HV4by8c=; b=OOjQD7PcaDHf9UqHMUXZOqvvQUGIPQRaLs3BA8ro+eCzT5qcQF4w+fnt9LRl8ccedp 4Dx6UUTBdQaTzpoZpcNCXp6v+1Gfo1Ao5EGEHNuIO4xqiFzSgWuteSmJIH1ZAu3Iwzy9 LV3pf93r2TtAQdJyRNzsLefPU43hIGGoffl4ejQsjQR7Li8I0Nq+PX8NbDsMH2HbY4Vw Bg22w2rum1KXFoojqSWHhEW1XrIuMtUDgMAjuN0HWQkd7qzyW6IX+hOSWQb5R/gQ6n5i lT+OQ30Er1Cr1KewCuA08VWXh/1Jk/KlOFVrZPjvFB/hFWx9ztUjOfP0f7nIlYEI5qxL k3vw== 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:mime-version:content-transfer-encoding; bh=IzUUD53TRCina4FvQp5wgcW+VoUOyAwWBEy3HV4by8c=; b=Yt2EXE4/eHju+weT5693wwIzYK9BKvia8RpUJ7fGgtGdPFBk4djVT5whsTG1Vv0iHN 6T13TIE0u2IXhnexjoBIr8otkhW49Fduh/5JkoB3nHvVv2JW0ejwc/e0nIWHPAGYXh6h yw4uDJwexPCDwmCp2IFjZUkJFi9dQ8Y7JLk7tgF8RjphxYFyLYn8nh4Q4lhBr2jzW+qZ Cj5IQSPMqHlsnqy8MqId1t8B4ZcTCmQS6BtEfupu7eqNJv6LWFl7YxuRbftMJtDBoxrE Gw7qFcE+4iBXuagC1NIyTI6npouo2besWO0AsTO5W2UauKDcfE2OpVZXRDzqQLSzLuod AnRQ== X-Gm-Message-State: AOAM530HjztK1YHPy8Zr+5becyfVOEDZL3yUy2UwlgSWAp6uvT4PocU6 JYdRJMcBCIVgbBwhqP+v2Ls/XxG9+74= X-Google-Smtp-Source: ABdhPJzagBDIHTv/jV31+XINjnPPk9hLtJ8OsAkBF08ftXKkvaqBJhCvGvI5pV20pDU+sfVjwGN8Iw== X-Received: by 2002:a17:90a:8801:: with SMTP id s1mr6291123pjn.166.1630426370486; Tue, 31 Aug 2021 09:12:50 -0700 (PDT) Received: from localhost (c-73-25-156-94.hsd1.or.comcast.net. [73.25.156.94]) by smtp.gmail.com with ESMTPSA id a21sm3515990pjo.14.2021.08.31.09.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Aug 2021 09:12:49 -0700 (PDT) From: Rob Clark To: igt-dev@lists.freedesktop.org Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Jordan Crouse , Akhil P Oommen , Petri Latvala , Rob Clark Subject: [PATCH igt v4 1/3] drmtest: Add DRIVER_MSM support Date: Tue, 31 Aug 2021 09:17:14 -0700 Message-Id: <20210831161716.1400057-2-robdclark@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210831161716.1400057-1-robdclark@gmail.com> References: <20210831161716.1400057-1-robdclark@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Rob Clark Signed-off-by: Rob Clark Reviewed-by: Petri Latvala --- lib/drmtest.c | 3 +++ lib/drmtest.h | 1 + 2 files changed, 4 insertions(+) diff --git a/lib/drmtest.c b/lib/drmtest.c index e1f9b115..29cb3f4c 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -179,6 +179,7 @@ static const struct module { } modules[] = { { DRIVER_AMDGPU, "amdgpu" }, { DRIVER_INTEL, "i915", modprobe_i915 }, + { DRIVER_MSM, "msm" }, { DRIVER_PANFROST, "panfrost" }, { DRIVER_V3D, "v3d" }, { DRIVER_VC4, "vc4" }, @@ -539,6 +540,8 @@ static const char *chipset_to_str(int chipset) return "amdgpu"; case DRIVER_PANFROST: return "panfrost"; + case DRIVER_MSM: + return "msm"; case DRIVER_ANY: return "any"; default: diff --git a/lib/drmtest.h b/lib/drmtest.h index 7d17a0f9..a6eb60c3 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -50,6 +50,7 @@ #define DRIVER_AMDGPU (1 << 3) #define DRIVER_V3D (1 << 4) #define DRIVER_PANFROST (1 << 5) +#define DRIVER_MSM (1 << 6) /* * Exclude DRVER_VGEM from DRIVER_ANY since if you run on a system From patchwork Tue Aug 31 16:17:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 504671 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 8803DC432BE for ; Tue, 31 Aug 2021 16:12:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B12861041 for ; Tue, 31 Aug 2021 16:12:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239804AbhHaQNu (ORCPT ); Tue, 31 Aug 2021 12:13:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239794AbhHaQNu (ORCPT ); Tue, 31 Aug 2021 12:13:50 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1125CC061760 for ; Tue, 31 Aug 2021 09:12:55 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id r2so17201808pgl.10 for ; Tue, 31 Aug 2021 09:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BJ0YEXpLntU+DOTXnIO553DfxMRSTnMyz1rQxbWIyZ4=; b=kaycFKO/e4q8FWOCk9ib7tFhoGJB6B2rn+nmscd0ednZGWxnR3QGol70O9E/jAmJrM DYjj0oPsePfdtwPGgGl56m/5QWAYTYL26DGYsLPqsXywnlDoQz3SR1++rgG/TPjfLevJ 2fWeKUMOe0nGAjSGU6QSYlnOWunforN1diODGjqzHyHMyv2vDasCqjDvzvevj6JEnRBc bOs6Z9WT8zJNJnHIBy+6mXh9osBWN/jjoz/AtNZF0rZeTZtQrKGezvSusBCZpSkXxKNK akHxrliFMdj3maQxbjth/j6eQlApU3gl/6A05MBGcxFHQBCw0hU9qiGYErO8PWCm0ZPs Ugag== 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:mime-version:content-transfer-encoding; bh=BJ0YEXpLntU+DOTXnIO553DfxMRSTnMyz1rQxbWIyZ4=; b=LbDMbsCPeashEE1Y2WywI47I2DwtQe7054I0zy3R6rMNlbhvp7EGEh2KM+HPZXNy7X U9zCPuUdlnvIuKPjhTnFVuKIZ3/JdE+tuNyqA5WafNip6MxH5chWqEXILYv8BL/I5yQy L38hw8uLkb4wM7zHstcAh0AyIWbSHqXXfyQhXsmBBwxwtw/SHgt+F4sf5WM0Wxf8dUQn KMZ/NHOoDlaGNVek7hLHrn6dJvZ7oOMnoLvNuo50Xrs5ba+XI3mzg0XY4p2J+uMDGoWV OrQqg/MshWcIyzZ1vh1kamRRjdxLSFrQdHS7UnCNMUBXqN/uR9J0FfmlbX8roX/TPdn7 M/Mg== X-Gm-Message-State: AOAM532cn2ZM1MS4XFbWGZSg3zyDvhBo9vgTDVku71tFs1VCE381oSWl B3r03FHEGINsgaNnN0T+60Q= X-Google-Smtp-Source: ABdhPJyJKerZEWDMveCSFJRpMnuR3ZSgxGElQ9kyw7BfOpeMGhiDytDvsi/G8KGaZNFXlBeCqQ9z6Q== X-Received: by 2002:a63:4455:: with SMTP id t21mr27386813pgk.91.1630426374549; Tue, 31 Aug 2021 09:12:54 -0700 (PDT) Received: from localhost (c-73-25-156-94.hsd1.or.comcast.net. [73.25.156.94]) by smtp.gmail.com with ESMTPSA id b5sm14025835pfr.26.2021.08.31.09.12.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Aug 2021 09:12:53 -0700 (PDT) From: Rob Clark To: igt-dev@lists.freedesktop.org Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Jordan Crouse , Akhil P Oommen , Petri Latvala , Rob Clark Subject: [PATCH igt v4 3/3] msm: Add submit ioctl tests Date: Tue, 31 Aug 2021 09:17:16 -0700 Message-Id: <20210831161716.1400057-4-robdclark@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210831161716.1400057-1-robdclark@gmail.com> References: <20210831161716.1400057-1-robdclark@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Rob Clark Add an initial set of tests for the submit ioctl. v2: Add NULL inits, igt_describe() v3: Alphabetize meson.build Signed-off-by: Rob Clark Acked-by: Petri Latvala --- tests/meson.build | 1 + tests/msm_submit.c | 194 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+) create mode 100644 tests/msm_submit.c diff --git a/tests/meson.build b/tests/meson.build index 1bdfddbb..cbc02534 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -78,6 +78,7 @@ test_progs = [ 'kms_vrr', 'kms_writeback', 'meta_test', + 'msm_submit', 'panfrost_get_param', 'panfrost_gem_new', 'panfrost_prime', diff --git a/tests/msm_submit.c b/tests/msm_submit.c new file mode 100644 index 00000000..95f8318f --- /dev/null +++ b/tests/msm_submit.c @@ -0,0 +1,194 @@ +/* + * Copyright © 2021 Google, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "igt.h" +#include "igt_msm.h" + +igt_main +{ + struct msm_device *dev = NULL; + struct msm_pipe *pipe = NULL; + struct msm_bo *a = NULL, *b = NULL; + + igt_fixture { + dev = igt_msm_dev_open(); + pipe = igt_msm_pipe_open(dev, 0); + a = igt_msm_bo_new(dev, 0x1000, MSM_BO_WC); + b = igt_msm_bo_new(dev, 0x1000, MSM_BO_WC); + } + + igt_describe("Check that a valid empty submit succeeds"); + igt_subtest("empty-submit") { + struct drm_msm_gem_submit req = { + .flags = pipe->pipe, + .queueid = pipe->submitqueue_id, + }; + do_ioctl(dev->fd, DRM_IOCTL_MSM_GEM_SUBMIT, &req); + } + + igt_describe("Check that submit with invalid submitqueue id fails"); + igt_subtest("invalid-queue-submit") { + struct drm_msm_gem_submit req = { + .flags = pipe->pipe, + .queueid = 0x1234, + }; + do_ioctl_err(dev->fd, DRM_IOCTL_MSM_GEM_SUBMIT, &req, ENOENT); + } + + igt_describe("Check that submit with invalid flags fails"); + igt_subtest("invalid-flags-submit") { + struct drm_msm_gem_submit req = { + .flags = 0x1234, + .queueid = pipe->submitqueue_id, + }; + do_ioctl_err(dev->fd, DRM_IOCTL_MSM_GEM_SUBMIT, &req, EINVAL); + } + + igt_describe("Check that submit with invalid in-fence fd fails"); + igt_subtest("invalid-in-fence-submit") { + struct drm_msm_gem_submit req = { + .flags = pipe->pipe | MSM_SUBMIT_FENCE_FD_IN, + .queueid = pipe->submitqueue_id, + .fence_fd = dev->fd, /* This is not a fence fd! */ + }; + do_ioctl_err(dev->fd, DRM_IOCTL_MSM_GEM_SUBMIT, &req, EINVAL); + } + + igt_describe("Check that submit with duplicate bo fails"); + igt_subtest("invalid-duplicate-bo-submit") { + struct drm_msm_gem_submit_bo bos[] = { + [0] = { + .handle = a->handle, + .flags = MSM_SUBMIT_BO_READ, + }, + [1] = { + .handle = b->handle, + .flags = MSM_SUBMIT_BO_READ, + }, + [2] = { + /* this is invalid.. there should not be two entries + * for the same bo, instead a single entry w/ all + * usage flags OR'd together should be used. Kernel + * should catch this, and return an error code after + * cleaning up properly (not leaking any bo's) + */ + .handle = a->handle, + .flags = MSM_SUBMIT_BO_WRITE, + }, + }; + struct drm_msm_gem_submit req = { + .flags = pipe->pipe, + .queueid = pipe->submitqueue_id, + .nr_bos = ARRAY_SIZE(bos), + .bos = VOID2U64(bos), + }; + do_ioctl_err(dev->fd, DRM_IOCTL_MSM_GEM_SUBMIT, &req, EINVAL); + } + + igt_describe("Check that submit with cmdstream referencing an invalid bo fails"); + igt_subtest("invalid-cmd-idx-submit") { + struct drm_msm_gem_submit_cmd cmds[] = { + [0] = { + .type = MSM_SUBMIT_CMD_BUF, + .submit_idx = 0, /* bos[0] does not exist */ + .size = 4 * 4, /* 4 dwords in cmdbuf */ + }, + }; + struct drm_msm_gem_submit req = { + .flags = pipe->pipe, + .queueid = pipe->submitqueue_id, + .nr_cmds = ARRAY_SIZE(cmds), + .cmds = VOID2U64(cmds), + }; + do_ioctl_err(dev->fd, DRM_IOCTL_MSM_GEM_SUBMIT, &req, EINVAL); + } + + igt_describe("Check that submit with invalid cmdstream type fails"); + igt_subtest("invalid-cmd-type-submit") { + struct drm_msm_gem_submit_bo bos[] = { + [0] = { + .handle = a->handle, + .flags = MSM_SUBMIT_BO_READ, + }, + }; + struct drm_msm_gem_submit_cmd cmds[] = { + [0] = { + .type = 0x1234, + .submit_idx = 0, + .size = 4 * 4, /* 4 dwords in cmdbuf */ + }, + }; + struct drm_msm_gem_submit req = { + .flags = pipe->pipe, + .queueid = pipe->submitqueue_id, + .nr_cmds = ARRAY_SIZE(cmds), + .cmds = VOID2U64(cmds), + .nr_bos = ARRAY_SIZE(bos), + .bos = VOID2U64(bos), + }; + do_ioctl_err(dev->fd, DRM_IOCTL_MSM_GEM_SUBMIT, &req, EINVAL); + } + + igt_describe("Check that a valid non-empty submit succeeds"); + igt_subtest("valid-submit") { + struct drm_msm_gem_submit_bo bos[] = { + [0] = { + .handle = a->handle, + .flags = MSM_SUBMIT_BO_READ, + }, + }; + struct drm_msm_gem_submit_cmd cmds[] = { + [0] = { + .type = MSM_SUBMIT_CMD_BUF, + .submit_idx = 0, + .size = 4 * 4, /* 4 dwords in cmdbuf */ + }, + }; + struct drm_msm_gem_submit req = { + .flags = pipe->pipe, + .queueid = pipe->submitqueue_id, + .nr_cmds = ARRAY_SIZE(cmds), + .cmds = VOID2U64(cmds), + .nr_bos = ARRAY_SIZE(bos), + .bos = VOID2U64(bos), + }; + uint32_t *cmdstream = igt_msm_bo_map(a); + if (dev->gen >= 5) { + *(cmdstream++) = pm4_pkt7_hdr(CP_NOP, 3); + } else { + *(cmdstream++) = pm4_pkt3_hdr(CP_NOP, 3); + } + *(cmdstream++) = 0; + *(cmdstream++) = 0; + *(cmdstream++) = 0; + + do_ioctl(dev->fd, DRM_IOCTL_MSM_GEM_SUBMIT, &req); + } + + igt_fixture { + igt_msm_bo_free(a); + igt_msm_bo_free(b); + igt_msm_pipe_close(pipe); + igt_msm_dev_close(dev); + } +}