From patchwork Wed Aug 25 23:31:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 502970 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 E5173C432BE for ; Wed, 25 Aug 2021 23:27:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4C966108E for ; Wed, 25 Aug 2021 23:27:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233291AbhHYX2H (ORCPT ); Wed, 25 Aug 2021 19:28:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231535AbhHYX2H (ORCPT ); Wed, 25 Aug 2021 19:28:07 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECB4AC061757 for ; Wed, 25 Aug 2021 16:27:20 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id j4-20020a17090a734400b0018f6dd1ec97so920462pjs.3 for ; Wed, 25 Aug 2021 16:27:20 -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=6rbkJU5Og6H1G2/+RhkyDxpDT8jQjtOSrnMdlUzo1BM=; b=HgrSvM72m3zLW4Qd+/L57IQD7eRaWgq7TpYUsRMxP6bAYgmHkb35ZXwdZ3zR7oCjIW m84MVBpYf0P0XI0u4Sae3UCF3FZbyjfWwu2yxGB9SIsckzyEkXjaV5/EcBEM1AeKiiVR 0S47860H4itWT3W3KmtcFd3QcG3SZpi9JgJdFEJdhJ4AJOq+zoEqvsF0dc/FXT0+OYb7 3rsQ4twoJhj2xdwYwPm5PxbdS6e6QkhA4ewXeQrmmyjgqgiBMMH9XkR2KvyGiKR65Rzq u+OPyrs1GI6GjSkv4gxIr5AVDmiiKrpYz/wEMeRf5xKWr9cEzAO+/c9bpbF4eB4ZiTMo v9cQ== 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=6rbkJU5Og6H1G2/+RhkyDxpDT8jQjtOSrnMdlUzo1BM=; b=mUXH/woFpfBkueMqO7skDCO9XFBXR6O9oQg6iHUV9NXYuWsKZGhPEzs/5PKsW/prTy FeXu0B6M7WgHXx1z59JWAOUjwHpcwLoRKcpCh0Lemwj0apVJym2pJok09XsRPv99KSnt dN9N7Rfq62ghAchjDG4ypTsbWS/8X3yB4cPPTlD/o0c3GFTjJfIG1Lf9SezqzuWSq/or 0/0etT8DNqDPy782agdVv1RO6+Q/Xxu4NZ+dHRr00FaXMOXfRToNkKlbd2ooomJ/8e6w 7X5XWBu4o+4NasSSJCJLnAY4X7nTN+6zeTIzQi8iIzAIIlC03mAaNl5p95/4HZyzgcXK ncLg== X-Gm-Message-State: AOAM531BjPhgIaJmbGOeN0VxQe0zKOS4WQoqtowH6YhdFuBVQiJ+9wbI nZO3WFLgjKlPtjXktm4nYps= X-Google-Smtp-Source: ABdhPJyuM3yU1udzOEvRaP7Uhd8O10/38NggoCBg1bTFLmGzKOLvE7/w+qBcRM2Dh38orYnHDtEn2g== X-Received: by 2002:a17:902:7049:b0:131:bdef:522d with SMTP id h9-20020a170902704900b00131bdef522dmr837390plt.85.1629934040417; Wed, 25 Aug 2021 16:27:20 -0700 (PDT) Received: from localhost ([2601:1c0:5200:a6:307:a401:7b76:c6e5]) by smtp.gmail.com with ESMTPSA id w3sm738683pfn.96.2021.08.25.16.27.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 16:27:19 -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 v2 3/3] msm: Add submit ioctl tests Date: Wed, 25 Aug 2021 16:31:39 -0700 Message-Id: <20210825233139.1066504-4-robdclark@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210825233139.1066504-1-robdclark@gmail.com> References: <20210825233139.1066504-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 | 186 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 187 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..da93c574 --- /dev/null +++ b/tests/msm_submit.c @@ -0,0 +1,186 @@ +/* + * 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; + + 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_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 (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); + } +}