From patchwork Tue Aug 24 22:49:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 501854 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.7 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, 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 42BD9C4338F for ; Tue, 24 Aug 2021 22:45:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2325661357 for ; Tue, 24 Aug 2021 22:45:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231135AbhHXWqB (ORCPT ); Tue, 24 Aug 2021 18:46:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230488AbhHXWqB (ORCPT ); Tue, 24 Aug 2021 18:46:01 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3D1DC061757 for ; Tue, 24 Aug 2021 15:45:16 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id q21so4168239plq.3 for ; Tue, 24 Aug 2021 15:45:16 -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=ZO3zKGF+0NhPfL8Qd0KyZNcW2ZWya+gJqC9s4ZSXqFs=; b=BzNv75Zr8IZ+hw0SmOgWUVI+t/muib2et+OpiUcjIxoO5Ui0Tc1XPwUoO9SIFikroZ fd59sugOcPUw8VIIgJyvAVQhFkffYNODQgB60w3tfkLHazc3oZYYhm3PwebDSkDbayJ+ uld53ZOkTMKbarFjKmjyaByW96qMyEbEsn+FQPocfOzRiQenL6lB1MlNoufsFQtD0b01 CVCUErC06YYs8T2BH8rxV2+iHjkuZQwwHjg2GXuNPJmHD6bkYhe/zAboVediAZjMCCDW eojcfAjng9zBpP+/+Su1xdYN0ExyMRbi3NApLWM239FQZQxgJxU+vHHA+AMUBWSGLaCj hixQ== 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=ZO3zKGF+0NhPfL8Qd0KyZNcW2ZWya+gJqC9s4ZSXqFs=; b=BWiWeNEXSJH2HbdVbX7PctstB5ZKM99iVqUd0cw3ei8Mm6UXPjiriLsE0MMMpf4272 PyKcVz36aGRd+wgakto8SdQIgjzrvI7sWd79yRPJjVDhcipmYLy9eazWMznsp9cIv1pj Xe5i07kry76sSFQ8/P9j9zBOfDB2KrG4G5co2aE5gDt+XiPQGe1XXHnmHm/DEbiTAHGB driC+FOQ0sucDLjOhh4PsdE+DcZ+NtLCo+rMitRnL4fpdsZKtT0X5Gdu3QpUlSkQ2j/Q SE6ZOo7jTSMYUMm/RORIq957A8XmZSlDjqKDogmBvi3POvfwrkrTvlSEUpnp1L4ktW2g F+9g== X-Gm-Message-State: AOAM532PnzsuBK+rar1CAmM3LlbDNwIjlxqHKE9tCChttZjf0YJjBpIX ImPrE0jM0FgDY7mKOIxAFV8U0cyAfMQ= X-Google-Smtp-Source: ABdhPJzGNTvS5lR8yl9Ds5jQal5mlDin3DlRgDDSCvzupDXRXDIjxs8xLKVsoNBcmmfmCULDA/u2nw== X-Received: by 2002:a17:902:b20e:b029:12b:fd6f:44c3 with SMTP id t14-20020a170902b20eb029012bfd6f44c3mr35011809plr.36.1629845116478; Tue, 24 Aug 2021 15:45:16 -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 o11sm20716569pfd.124.2021.08.24.15.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Aug 2021 15:45:15 -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 , Rob Clark Subject: [PATCH igt 1/3] drmtest: Add DRIVER_MSM support Date: Tue, 24 Aug 2021 15:49:30 -0700 Message-Id: <20210824224932.564352-2-robdclark@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210824224932.564352-1-robdclark@gmail.com> References: <20210824224932.564352-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 --- 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 24 22:49:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 501853 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.7 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, 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 820F1C4320A for ; Tue, 24 Aug 2021 22:45:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 69AA161357 for ; Tue, 24 Aug 2021 22:45:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230488AbhHXWqG (ORCPT ); Tue, 24 Aug 2021 18:46:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231300AbhHXWqG (ORCPT ); Tue, 24 Aug 2021 18:46:06 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AF85C061757 for ; Tue, 24 Aug 2021 15:45:21 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id m4so2122280pll.0 for ; Tue, 24 Aug 2021 15:45:21 -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=AIQD0/ed7PF/KiqM//O+N8hKXcL86AFA/U8Q7Sp3t2s=; b=N1zibkPfV1UtZ6x/hyhOeDsGuESlkGZsI4+9LaAQFRDVOfujT9KFpZrzzx0NJ47Hxz JjgCb6EwDlzIoYbI5/rXp6RG0qPCDvDFfJtp1L1krwR08//xZATeSJy3FbLET9LuBs1C Lg9+kXFtXTv6czlB4njeZ6uk0KxNcRGn2EU6MPQxaHyuNgyAJWAwblqtTVjRGKV5Ql1n wnE/5T/I4V4eEg7eq+qVSo7M84IXPNNvd8vaTulv3uRUPS5AcAIDxKo6LjF21rh+Hmt/ aYdslgZyOPP+wLR0Nnk3RSbFn4qm5skbTSw02nJKk4kmIXFyw1cvQ8cXbjmE3WshCs5Y i6gg== 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=AIQD0/ed7PF/KiqM//O+N8hKXcL86AFA/U8Q7Sp3t2s=; b=N23pMk4LMjYa8HLpwEuxOtoaFgt4U3BCbVwdEQBmJBKysH2ckQ2Vb8TkCWDOYK/G3Y dzUpAEgoSR7ck3ud0HvP5Oo/TfplwLOiSS0izx1AlB8K2szK1Ly5nwZ4I5Bzco3VYlET owW+LuC6VMaFcwEo9Tl/abGtZJAnI96NqJq0I6uYvC+HWqC8yR9piyO4AVfBhanBeWhf OPO5+bf6pi2M2iWelb0KA+nR2i9EXdYSeVHsksqd3quuvt+w00kls6f7BYO/ixxYj/Ol JTsLuufDkoDoiDwZZAKmcbEvDzJqofYUyv2bClIGaUDnQZY7KastrNJnCrK6onmvD+WN tP8A== X-Gm-Message-State: AOAM532ygsS9kRdED2/zANYE2viRbmbViUjjtHMIPn8Wnsd5tDo+xu3K HW4z1mPXeZehb59ZkR6LXSw= X-Google-Smtp-Source: ABdhPJyGFr6UDKRqejYTXEUWTOUWKig004QMvmFR7OMWzG4fYTxdp9gyW3NOmdHQYybPUaL4nXT5mA== X-Received: by 2002:a17:90a:1f09:: with SMTP id u9mr6838263pja.206.1629845120833; Tue, 24 Aug 2021 15:45:20 -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 11sm19814433pfl.41.2021.08.24.15.45.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Aug 2021 15:45:20 -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 , Rob Clark Subject: [PATCH igt 3/3] msm: Add submit ioctl tests Date: Tue, 24 Aug 2021 15:49:32 -0700 Message-Id: <20210824224932.564352-4-robdclark@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210824224932.564352-1-robdclark@gmail.com> References: <20210824224932.564352-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. Signed-off-by: Rob Clark --- tests/meson.build | 1 + tests/msm_submit.c | 188 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 189 insertions(+) create mode 100644 tests/msm_submit.c diff --git a/tests/meson.build b/tests/meson.build index 1bdfddbb..ff7c709a 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -107,6 +107,7 @@ test_progs = [ 'vc4_wait_seqno', 'vgem_basic', 'vgem_slow', + 'msm_submit', ] i915_progs = [ diff --git a/tests/msm_submit.c b/tests/msm_submit.c new file mode 100644 index 00000000..9c7d6d4b --- /dev/null +++ b/tests/msm_submit.c @@ -0,0 +1,188 @@ +/* + * 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; + struct msm_pipe *pipe; + struct msm_bo *a, *b; + unsigned gen; + + igt_fixture { + dev = igt_msm_dev_open(); + pipe = igt_msm_pipe_open(dev, 0); + gen = igt_msm_pipe_gen(pipe); + a = igt_msm_bo_new(dev, 0x1000, MSM_BO_WC); + b = igt_msm_bo_new(dev, 0x1000, MSM_BO_WC); + } + + 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_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_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_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_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_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_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_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 (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); + } +}