aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrey Grodzovsky2017-10-27 10:09:11 -0500
committerChristian König2017-10-27 11:26:08 -0500
commit33dcc29f7ccc554de1fc42f4b95adf056822eabb (patch)
tree61210e7313ee67bf0c071d666dc9d520014ba391 /tests
parent9b38ea82fc30ccbf38ebc0c55412b27e5a5afd7b (diff)
downloadexternal-libdrm-33dcc29f7ccc554de1fc42f4b95adf056822eabb.tar.gz
external-libdrm-33dcc29f7ccc554de1fc42f4b95adf056822eabb.tar.xz
external-libdrm-33dcc29f7ccc554de1fc42f4b95adf056822eabb.zip
amdgpu: Add VMID reservation per GPU context test.
The test will Reserve a VMID, submit a command and unreserve the VMID. v2: Wrappers names were changed. Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/amdgpu/Makefile.am3
-rw-r--r--tests/amdgpu/amdgpu_test.c7
-rw-r--r--tests/amdgpu/amdgpu_test.h15
-rw-r--r--tests/amdgpu/vm_tests.c151
4 files changed, 175 insertions, 1 deletions
diff --git a/tests/amdgpu/Makefile.am b/tests/amdgpu/Makefile.am
index 8700c4d4..e79c1bd3 100644
--- a/tests/amdgpu/Makefile.am
+++ b/tests/amdgpu/Makefile.am
@@ -31,4 +31,5 @@ amdgpu_test_SOURCES = \
31 uvd_enc_tests.c \ 31 uvd_enc_tests.c \
32 vcn_tests.c \ 32 vcn_tests.c \
33 uve_ib.h \ 33 uve_ib.h \
34 deadlock_tests.c 34 deadlock_tests.c \
35 vm_tests.c
diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c
index 99255038..a82d9ab1 100644
--- a/tests/amdgpu/amdgpu_test.c
+++ b/tests/amdgpu/amdgpu_test.c
@@ -103,6 +103,13 @@ static CU_SuiteInfo suites[] = {
103 .pCleanupFunc = suite_deadlock_tests_clean, 103 .pCleanupFunc = suite_deadlock_tests_clean,
104 .pTests = deadlock_tests, 104 .pTests = deadlock_tests,
105 }, 105 },
106 {
107 .pName = "VM Tests",
108 .pInitFunc = suite_vm_tests_init,
109 .pCleanupFunc = suite_vm_tests_clean,
110 .pTests = vm_tests,
111 },
112
106 CU_SUITE_INFO_NULL, 113 CU_SUITE_INFO_NULL,
107}; 114};
108 115
diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h
index ece93f4c..4fffbc62 100644
--- a/tests/amdgpu/amdgpu_test.h
+++ b/tests/amdgpu/amdgpu_test.h
@@ -150,6 +150,21 @@ int suite_deadlock_tests_clean();
150extern CU_TestInfo deadlock_tests[]; 150extern CU_TestInfo deadlock_tests[];
151 151
152/** 152/**
153 * Initialize vm test suite
154 */
155int suite_vm_tests_init();
156
157/**
158 * Deinitialize deadlock test suite
159 */
160int suite_vm_tests_clean();
161
162/**
163 * Tests in vm test suite
164 */
165extern CU_TestInfo vm_tests[];
166
167/**
153 * Helper functions 168 * Helper functions
154 */ 169 */
155static inline amdgpu_bo_handle gpu_mem_alloc( 170static 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 00000000..cbfafe97
--- /dev/null
+++ b/tests/amdgpu/vm_tests.c
@@ -0,0 +1,151 @@
1/*
2 * Copyright 2017 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22*/
23
24#include "CUnit/Basic.h"
25
26#include "amdgpu_test.h"
27#include "amdgpu_drm.h"
28
29static amdgpu_device_handle device_handle;
30static uint32_t major_version;
31static uint32_t minor_version;
32
33
34static void amdgpu_vmid_reserve_test(void);
35
36int suite_vm_tests_init(void)
37{
38 struct amdgpu_gpu_info gpu_info = {0};
39 int r;
40
41 r = amdgpu_device_initialize(drm_amdgpu[0], &major_version,
42 &minor_version, &device_handle);
43
44 if (r) {
45 if ((r == -EACCES) && (errno == EACCES))
46 printf("\n\nError:%s. "
47 "Hint:Try to run this test program as root.",
48 strerror(errno));
49 return CUE_SINIT_FAILED;
50 }
51
52 return CUE_SUCCESS;
53}
54
55int suite_vm_tests_clean(void)
56{
57 int r = amdgpu_device_deinitialize(device_handle);
58
59 if (r == 0)
60 return CUE_SUCCESS;
61 else
62 return CUE_SCLEAN_FAILED;
63}
64
65
66CU_TestInfo vm_tests[] = {
67 { "resere vmid test", amdgpu_vmid_reserve_test },
68 CU_TEST_INFO_NULL,
69};
70
71static void amdgpu_vmid_reserve_test(void)
72{
73 amdgpu_context_handle context_handle;
74 amdgpu_bo_handle ib_result_handle;
75 void *ib_result_cpu;
76 uint64_t ib_result_mc_address;
77 struct amdgpu_cs_request ibs_request;
78 struct amdgpu_cs_ib_info ib_info;
79 struct amdgpu_cs_fence fence_status;
80 uint32_t expired, flags;
81 int i, r, instance;
82 amdgpu_bo_list_handle bo_list;
83 amdgpu_va_handle va_handle;
84 union drm_amdgpu_vm vm;
85 static uint32_t *ptr;
86
87 r = amdgpu_cs_ctx_create(device_handle, &context_handle);
88 CU_ASSERT_EQUAL(r, 0);
89
90 flags = 0;
91 r = amdgpu_vm_reserve_vmid(context_handle, flags);
92 CU_ASSERT_EQUAL(r, 0);
93
94
95 r = amdgpu_bo_alloc_and_map(device_handle, 4096, 4096,
96 AMDGPU_GEM_DOMAIN_GTT, 0,
97 &ib_result_handle, &ib_result_cpu,
98 &ib_result_mc_address, &va_handle);
99 CU_ASSERT_EQUAL(r, 0);
100
101 r = amdgpu_get_bo_list(device_handle, ib_result_handle, NULL,
102 &bo_list);
103 CU_ASSERT_EQUAL(r, 0);
104
105 ptr = ib_result_cpu;
106
107 for (i = 0; i < 16; ++i)
108 ptr[i] = 0xffff1000;
109
110 memset(&ib_info, 0, sizeof(struct amdgpu_cs_ib_info));
111 ib_info.ib_mc_address = ib_result_mc_address;
112 ib_info.size = 16;
113
114 memset(&ibs_request, 0, sizeof(struct amdgpu_cs_request));
115 ibs_request.ip_type = AMDGPU_HW_IP_GFX;
116 ibs_request.ring = 0;
117 ibs_request.number_of_ibs = 1;
118 ibs_request.ibs = &ib_info;
119 ibs_request.resources = bo_list;
120 ibs_request.fence_info.handle = NULL;
121
122 r = amdgpu_cs_submit(context_handle, 0,&ibs_request, 1);
123 CU_ASSERT_EQUAL(r, 0);
124
125
126 memset(&fence_status, 0, sizeof(struct amdgpu_cs_fence));
127 fence_status.context = context_handle;
128 fence_status.ip_type = AMDGPU_HW_IP_GFX;
129 fence_status.ip_instance = 0;
130 fence_status.ring = 0;
131 fence_status.fence = ibs_request.seq_no;
132
133 r = amdgpu_cs_query_fence_status(&fence_status,
134 AMDGPU_TIMEOUT_INFINITE,0, &expired);
135 CU_ASSERT_EQUAL(r, 0);
136
137 r = amdgpu_bo_list_destroy(bo_list);
138 CU_ASSERT_EQUAL(r, 0);
139
140 r = amdgpu_bo_unmap_and_free(ib_result_handle, va_handle,
141 ib_result_mc_address, 4096);
142 CU_ASSERT_EQUAL(r, 0);
143
144 flags = 0;
145 r = amdgpu_vm_unreserve_vmid(context_handle, flags);
146 CU_ASSERT_EQUAL(r, 0);
147
148
149 r = amdgpu_cs_ctx_free(context_handle);
150 CU_ASSERT_EQUAL(r, 0);
151}