summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Xie <AlexBin.Xie@amd.com>2015-10-20 11:52:08 -0400
committerQiang Yu <Qiang.Yu@amd.com>2017-05-17 10:24:19 +0800
commit2740b4d1f14727cf16d24b813ad97909105dabdc (patch)
tree4c57d86806deebac959aeca7d239f87c01accc34
parentfd4ae170ff97e62f2685563bd07ec15b5567380c (diff)
amdgpu: SVM test v3
SWDEV-75927: Coarse Grain SVM support for OpenCL 2.0 Add SVM relevant test. v3: 2f8e2d2e4a406bc290986eac600f4263259b5ac5 [Jammy Zhou] amdgpu_svm_test part 35425ab8b66de8d9a375f62317c26ebe3c44b7bc amdgpu_svm_test part v2: 1. Update the description of this commit. 2. Fix an issue that the SVM feature should not be tested when SVM range is not supported. 3. Remove test for query function for general VM range. Signed-off-by: Alex Xie <AlexBin.Xie@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
-rw-r--r--tests/amdgpu/basic_tests.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c
index 8d5844b6..b10aeb0d 100644
--- a/tests/amdgpu/basic_tests.c
+++ b/tests/amdgpu/basic_tests.c
@@ -49,6 +49,7 @@ static void amdgpu_command_submission_multi_fence(void);
static void amdgpu_command_submission_sdma(void);
static void amdgpu_userptr_test(void);
static void amdgpu_semaphore_test(void);
+static void amdgpu_svm_test(void);
static void amdgpu_command_submission_write_linear_helper(unsigned ip_type);
static void amdgpu_command_submission_const_fill_helper(unsigned ip_type);
@@ -63,9 +64,11 @@ CU_TestInfo basic_tests[] = {
{ "Command submission Test (Multi-Fence)", amdgpu_command_submission_multi_fence },
{ "Command submission Test (SDMA)", amdgpu_command_submission_sdma },
{ "SW semaphore Test", amdgpu_semaphore_test },
+ { "SVM Test", amdgpu_svm_test },
CU_TEST_INFO_NULL,
};
#define BUFFER_SIZE (8 * 1024)
+#define SVM_TEST_COUNT 16
#define SDMA_PKT_HEADER_op_offset 0
#define SDMA_PKT_HEADER_op_mask 0x000000FF
#define SDMA_PKT_HEADER_op_shift 0
@@ -1329,3 +1332,54 @@ static void amdgpu_userptr_test(void)
r = amdgpu_cs_ctx_free(context_handle);
CU_ASSERT_EQUAL(r, 0);
}
+
+static void amdgpu_svm_test(void)
+{
+ int r;
+ uint64_t svm_mc;
+ amdgpu_va_handle va_handle[SVM_TEST_COUNT];
+ void *cpu;
+ uint64_t start;
+ uint64_t end;
+ int i;
+
+ r = amdgpu_svm_init(device_handle);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_va_range_query(device_handle,
+ amdgpu_gpu_va_range_svm, &start, &end);
+ CU_ASSERT_EQUAL(r, 0);
+ printf("\n");
+ printf("SVM range is from 0x%llx to 0x%llx.\n", start, end);
+
+ /* If there is no SVM range, exit this function.*/
+ if (start == 0ULL && end == 0ULL)
+ return;
+
+ CU_ASSERT(start < end);
+ CU_ASSERT(end - start >= 1ULL * 1024ULL * 1024ULL * 1024ULL);
+
+ for (i = 0; i < SVM_TEST_COUNT; i++) {
+ r = amdgpu_va_range_alloc(device_handle,
+ amdgpu_gpu_va_range_svm,
+ 64 * 1024 * 1024, 1, 0, &svm_mc,
+ &va_handle[i], 0);
+ CU_ASSERT_EQUAL(r, 0);
+ printf("Allocate SVM MC 0x%llx.\n", svm_mc);
+
+ r = amdgpu_svm_commit(va_handle[i], &cpu);
+ CU_ASSERT_EQUAL(r, 0);
+ CU_ASSERT_PTR_NOT_NULL(cpu);
+ CU_ASSERT_EQUAL(svm_mc, (uint64_t)cpu);
+ }
+
+ for (i = 0; i < SVM_TEST_COUNT; i++) {
+ r = amdgpu_svm_uncommit(va_handle[i]);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_va_range_free(va_handle[i]);
+ CU_ASSERT_EQUAL(r, 0);
+ }
+
+ amdgpu_svm_deinit(device_handle);
+}