From patchwork Fri Oct 27 15:09:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 10030167 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 5414F602D6 for ; Fri, 27 Oct 2017 15:24:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EDDF2844E for ; Fri, 27 Oct 2017 15:24:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 311D328538; Fri, 27 Oct 2017 15:24:38 +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=BAD_ENC_HEADER,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 962302844E for ; Fri, 27 Oct 2017 15:24:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C663B6E967; Fri, 27 Oct 2017 15:24:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 894 seconds by postgrey-1.35 at gabe; Fri, 27 Oct 2017 15:24:33 UTC Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0053.outbound.protection.outlook.com [104.47.38.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0A6026E007 for ; Fri, 27 Oct 2017 15:24:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=LOJV5C5kHRKpVknrKXaUwUFtEx9ct/HpXzhCVoVJWjQ=; b=cClKMm9JcGG0XOHXfSL+wJa2Mp9IgALY6jiQgG32iGepObnbVh2XNJnUd288i8z1qoWMe1HqFvoyrCpLV5UWnGQQzcKGW434IkM2EqBJEtbVGnDbkpeeKf2KGyZTm3vyT7l0fZ8430ig0yd7DAtbyFQcRUnskuvO7Nudy5zgpEE= Received: from MWHPR1201CA0009.namprd12.prod.outlook.com (10.174.253.19) by BN6PR12MB1443.namprd12.prod.outlook.com (10.172.24.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.178.6; Fri, 27 Oct 2017 15:09:34 +0000 Received: from BY2NAM03FT006.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::203) by MWHPR1201CA0009.outlook.office365.com (2603:10b6:301:4a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.178.6 via Frontend Transport; Fri, 27 Oct 2017 15:09:33 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV02.amd.com (165.204.84.17) by BY2NAM03FT006.mail.protection.outlook.com (10.152.84.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.178.5 via Frontend Transport; Fri, 27 Oct 2017 15:09:33 +0000 Received: from SCYBEXDAG01.amd.com (10.34.11.11) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 27 Oct 2017 10:09:32 -0500 Received: from ubuntu-1604-test.amd.com (172.27.225.147) by SCYBEXDAG01.amd.com (10.34.11.11) with Microsoft SMTP Server id 14.3.361.1; Fri, 27 Oct 2017 23:09:30 +0800 From: Andrey Grodzovsky To: , Subject: [PATCH libdrm v2 2/2] amdgpu: Add VMID reservation per GPU context test. Date: Fri, 27 Oct 2017 11:09:11 -0400 Message-ID: <1509116951-1250-2-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509116951-1250-1-git-send-email-andrey.grodzovsky@amd.com> References: <1509116951-1250-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(346002)(376002)(39860400002)(2980300002)(428002)(199003)(189002)(6666003)(305945005)(97736004)(47776003)(110136005)(16586007)(2950100002)(356003)(316002)(77096006)(72206003)(54906003)(5003940100001)(86362001)(39060400002)(5660300001)(53416004)(101416001)(106466001)(8936002)(81166006)(76176999)(48376002)(189998001)(50986999)(68736007)(105586002)(4326008)(50466002)(478600001)(81156014)(2906002)(8676002)(33646002)(53936002)(36756003)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1443; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2NAM03FT006; 1:sS9yuj8HKnY0UMqVgJuoad254O2K0dXi476fFXOmLwcEnJ8CIV3uSUBz/N5Liv+0L7yLFnaEFRY4B3Z/kEwF+/EEPuhbQi1G5PF68xWpn0JyWqgDX/XeUYvSNupBXQb8 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9aa9391b-fb69-4c45-12c9-08d51d4cbb1b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627075)(201703031133081)(201702281549075)(2017052603199); SRVR:BN6PR12MB1443; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1443; 3:QGh1UI50+e69+yLVxpjbMogc/DPQAWdYD8FBYl31JK1AWpmMMD07itGF+1wkZJiBfDOPjL7qhpbFKeJyA4YZ+E8DOJkALYdqWVX+YjWzOt6n/rw6NCFhra3A2ZBB6KElXLkTdg3sbtuABLBSy0LQlKHhkbIXGQNP2wJIQ1ft0aZpP5kIQSpHkSANcW6pjWPEHdiDR5Y9QBjthm//Bsf6F1R6ELNt3jF/deetiMRPTE256D4DUGCr2XUj3wASAioSXx6iFCChljda78i2df+NanHR8LOyOobjXvFfPml0edKjjM0XiduAIyB1cAUAffLBCQFrU9dlbNxvQ9n/ilTd8IU+3NOUQ4MUNbnx0RuoyXU=; 25:bgxvdO1tj0xV1BEdll7ZXHaQl8P1hikjyupA2r56uNMj7MMjHYP53lyYVZcE8rXri6qk48tqytLOddB3BoWGxMWBEawwMCR/GJ2MmdCZDm7A3K6nS+6bZKFN4M+9uzglOgmp95oEL2w8Qpc0xscQK4Q3y2ViUYlEj0yMVnSIizb5sykgfGBpkrIY60l57x6pE3SIo8qHrzHJ0cGSzCpAvlfrb4SSJ/in2XV7d7gafjOFp+id1JWIScfF3Hyvy0NA90iEj43A1jRFvvW4QhZoqWgCc5dqWFqV20oBEQofpMPhFXhdqUBO88cQGqdeEbkb/gflR5B1qsyWt+O7tPxiAA== X-MS-TrafficTypeDiagnostic: BN6PR12MB1443: X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1443; 31:aRf0GiEbtE59pcUNWd+zMNMGqSFNEaEYb+HzBnmJkbRlwV6mVd+ve2UwjLhk0c+UTg9xCZ3DHUdllnhM85rEp8bwXnXb4s0iy3pCRLoi2UVMbm0yXmKLa1MdrGCkxXCJqSDdH9egrD7dMEJA9/el1JT1uShtqQPolfXWK4Kp+4AMM7B16wstJtvHuFd3GNF58tbxmEtS+Vdoz7vj4q2Z+lMrMFwNtoL32Lb+vDfo9sY=; 20:9PGnk3bm6G2bmOt3Jg0gquXwyzhh1SZX1gv0CLw9acaqDXqHa7paAc4VpjUbNveIdP3Y+0rg6MCRhVNlOP3Qa3y210JCW+xk5Fh3lX7QhT6Sx9lxwAp9kn3wcDZw2XAUtw5POHA+Wm6bL4rNvRGaRMSm3aKb8BU+vK2F5Q+QZ33aRwNBPzw0RG+fs3JFr/O7uxUd2vrDytph3SJPTcyN9LdXCA7WSS+g1sLKnKsFfhIXOXzO5zzmbNjeD4K4yCVRQsKSFlfSpFzGIfn1coq5cY1eZI0d6W6S4T8QPPOY84vaGbgNQyfLN3KL3f5K6FZ+45zpwapmxKp6zRPcRS3n2xrX4AjqrggNRzwM+dhgXQW5EZk10sCaU6zAvgFaNycg30DQggsH2oH9yivA+TbywmZ60O8WP1u3JRyaXRXZdcBHQ53ZHWdj2avHHTOu+gD79knFbr4yRnBqFYtyIrCZxAVx2kmDymP8J4fXhRX76MRvh66YIJt2H9nkKiu/BLnN X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(93006095)(93003095)(100000703101)(100105400095)(10201501046)(3231020)(3002001)(6055026)(6041248)(20161123555025)(20161123558100)(20161123560025)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR12MB1443; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR12MB1443; X-Microsoft-Ex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Ui9gcUI1kI=; 5:gtlXrfT21L1zN2UzuFDqn42utbtqoWvwxnjex1S8uvlfe72mcvd4Jg1giXk+TzlsKhn2rDgZFc4KqEYq15cvraqdmfhQeqmygsbbhBX1pUUq6b319IJXTWc80ju3Ubn0A1+FPt57N/F5CSJRG3HOjenRV67WYDVzkDzspJIrRwA=; 24:dhprmBLqpvfGhHkFO5V63st38NIntpz+l13q/B6W/eJjjC1Zok+zxeS7EtmqWCEiYR8dRJeq/COlYQP88y6pQ2Ye1/bZep29ELPf/CuS4RI=; 7:xoOZO1/rQfBgegmQ96NuQnQJFEDzvFyrnxdc7xaNVCjD5Wl0qm5dypMynTnVMzZ7xZptV8hNCPXjhMS0dUnma5yOiDJKu3CP01fLU1bgBXJqBGDSyxMB3wWAex319lxdRDFYC8O3qXm/dvQSeJ44ahsSS/hZD+Fw5GikFhqPLxKmU+f8Jw6zJ1ly3VW7XqZafeR/IxHYyzw0pM3X77xbv7xLqZ8SHExDCrE13/tA3GsAYzq4ZpDq/q5GIQHfjw3I SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1443; 20:WRe+s1hFji7cuR1ULiVJ1243iimwkUhHKi4xvhfGje1Aer9t8HQ+8O+qTGrWA+0T05wnWl5PBwfDV/ZSLSlbe4L8s28WzG+Hy2sWwbUR+Si1o9280p7KYPXj1NzahQaopnrb7PIrgykWp6hJXz/7CFkqNlpnRAvdWRt87IgxhoenCvxwm+Rn2wf951fj5YMIJNtYPjTMNrmykovPr3MQHlT3dzQS258NpomIj9DMlm9i3muaGQo+QKKidS9dmUwy X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2017 15:09:33.5064 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9aa9391b-fb69-4c45-12c9-08d51d4cbb1b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1443 Cc: emil.l.velikov@gmail.com, Christian.Koenig@amd.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Andrey Grodzovsky The test will Reserve a VMID, submit a command and unreserve the VMID. v2: Wrappers names were changed. Signed-off-by: Andrey Grodzovsky --- tests/amdgpu/Makefile.am | 3 +- tests/amdgpu/amdgpu_test.c | 7 +++ tests/amdgpu/amdgpu_test.h | 15 +++++ tests/amdgpu/vm_tests.c | 151 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 tests/amdgpu/vm_tests.c diff --git a/tests/amdgpu/Makefile.am b/tests/amdgpu/Makefile.am index 8700c4d..e79c1bd 100644 --- a/tests/amdgpu/Makefile.am +++ b/tests/amdgpu/Makefile.am @@ -31,4 +31,5 @@ amdgpu_test_SOURCES = \ uvd_enc_tests.c \ vcn_tests.c \ uve_ib.h \ - deadlock_tests.c + deadlock_tests.c \ + vm_tests.c diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c index 9925503..a82d9ab 100644 --- a/tests/amdgpu/amdgpu_test.c +++ b/tests/amdgpu/amdgpu_test.c @@ -103,6 +103,13 @@ static CU_SuiteInfo suites[] = { .pCleanupFunc = suite_deadlock_tests_clean, .pTests = deadlock_tests, }, + { + .pName = "VM Tests", + .pInitFunc = suite_vm_tests_init, + .pCleanupFunc = suite_vm_tests_clean, + .pTests = vm_tests, + }, + CU_SUITE_INFO_NULL, }; diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h index ece93f4..4fffbc6 100644 --- a/tests/amdgpu/amdgpu_test.h +++ b/tests/amdgpu/amdgpu_test.h @@ -150,6 +150,21 @@ int suite_deadlock_tests_clean(); extern CU_TestInfo deadlock_tests[]; /** + * Initialize vm test suite + */ +int suite_vm_tests_init(); + +/** + * Deinitialize deadlock test suite + */ +int suite_vm_tests_clean(); + +/** + * Tests in vm test suite + */ +extern CU_TestInfo vm_tests[]; + +/** * Helper functions */ static inline amdgpu_bo_handle gpu_mem_alloc( diff --git a/tests/amdgpu/vm_tests.c b/tests/amdgpu/vm_tests.c new file mode 100644 index 0000000..cbfafe9 --- /dev/null +++ b/tests/amdgpu/vm_tests.c @@ -0,0 +1,151 @@ +/* + * Copyright 2017 Advanced Micro Devices, 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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 "CUnit/Basic.h" + +#include "amdgpu_test.h" +#include "amdgpu_drm.h" + +static amdgpu_device_handle device_handle; +static uint32_t major_version; +static uint32_t minor_version; + + +static void amdgpu_vmid_reserve_test(void); + +int suite_vm_tests_init(void) +{ + struct amdgpu_gpu_info gpu_info = {0}; + int r; + + r = amdgpu_device_initialize(drm_amdgpu[0], &major_version, + &minor_version, &device_handle); + + if (r) { + if ((r == -EACCES) && (errno == EACCES)) + printf("\n\nError:%s. " + "Hint:Try to run this test program as root.", + strerror(errno)); + return CUE_SINIT_FAILED; + } + + return CUE_SUCCESS; +} + +int suite_vm_tests_clean(void) +{ + int r = amdgpu_device_deinitialize(device_handle); + + if (r == 0) + return CUE_SUCCESS; + else + return CUE_SCLEAN_FAILED; +} + + +CU_TestInfo vm_tests[] = { + { "resere vmid test", amdgpu_vmid_reserve_test }, + CU_TEST_INFO_NULL, +}; + +static void amdgpu_vmid_reserve_test(void) +{ + amdgpu_context_handle context_handle; + amdgpu_bo_handle ib_result_handle; + void *ib_result_cpu; + uint64_t ib_result_mc_address; + struct amdgpu_cs_request ibs_request; + struct amdgpu_cs_ib_info ib_info; + struct amdgpu_cs_fence fence_status; + uint32_t expired, flags; + int i, r, instance; + amdgpu_bo_list_handle bo_list; + amdgpu_va_handle va_handle; + union drm_amdgpu_vm vm; + static uint32_t *ptr; + + r = amdgpu_cs_ctx_create(device_handle, &context_handle); + CU_ASSERT_EQUAL(r, 0); + + flags = 0; + r = amdgpu_vm_reserve_vmid(context_handle, flags); + CU_ASSERT_EQUAL(r, 0); + + + r = amdgpu_bo_alloc_and_map(device_handle, 4096, 4096, + AMDGPU_GEM_DOMAIN_GTT, 0, + &ib_result_handle, &ib_result_cpu, + &ib_result_mc_address, &va_handle); + CU_ASSERT_EQUAL(r, 0); + + r = amdgpu_get_bo_list(device_handle, ib_result_handle, NULL, + &bo_list); + CU_ASSERT_EQUAL(r, 0); + + ptr = ib_result_cpu; + + for (i = 0; i < 16; ++i) + ptr[i] = 0xffff1000; + + memset(&ib_info, 0, sizeof(struct amdgpu_cs_ib_info)); + ib_info.ib_mc_address = ib_result_mc_address; + ib_info.size = 16; + + memset(&ibs_request, 0, sizeof(struct amdgpu_cs_request)); + ibs_request.ip_type = AMDGPU_HW_IP_GFX; + ibs_request.ring = 0; + ibs_request.number_of_ibs = 1; + ibs_request.ibs = &ib_info; + ibs_request.resources = bo_list; + ibs_request.fence_info.handle = NULL; + + r = amdgpu_cs_submit(context_handle, 0,&ibs_request, 1); + CU_ASSERT_EQUAL(r, 0); + + + memset(&fence_status, 0, sizeof(struct amdgpu_cs_fence)); + fence_status.context = context_handle; + fence_status.ip_type = AMDGPU_HW_IP_GFX; + fence_status.ip_instance = 0; + fence_status.ring = 0; + fence_status.fence = ibs_request.seq_no; + + r = amdgpu_cs_query_fence_status(&fence_status, + AMDGPU_TIMEOUT_INFINITE,0, &expired); + CU_ASSERT_EQUAL(r, 0); + + r = amdgpu_bo_list_destroy(bo_list); + CU_ASSERT_EQUAL(r, 0); + + r = amdgpu_bo_unmap_and_free(ib_result_handle, va_handle, + ib_result_mc_address, 4096); + CU_ASSERT_EQUAL(r, 0); + + flags = 0; + r = amdgpu_vm_unreserve_vmid(context_handle, flags); + CU_ASSERT_EQUAL(r, 0); + + + r = amdgpu_cs_ctx_free(context_handle); + CU_ASSERT_EQUAL(r, 0); +}