summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlora Cui <Flora.Cui@amd.com>2016-02-04 09:54:32 +0800
committerQiang Yu <Qiang.Yu@amd.com>2017-05-17 11:10:43 +0800
commit276889b2e10195e9773fb42ba211d5c2601b69d3 (patch)
tree21c43084f858229c6500107107e8d3e381589d8b
parent29dc49fbf19e4fca31adcace3e3e2e20faaecab9 (diff)
tests/amdgpu: add alloc va from range test v2
v2: ce907d89891ead5f26ffe821d47848a8c4241c82 move va_range_test above svm_test svm_test won't release va range at exit. va_range_test would desired range is occupied. Change-Id: Ie430345b42da6884d5296f057d4214b2d3f12788 Signed-off-by: Flora Cui <Flora.Cui@amd.com> Reviewed-by: Ken Wang <Qingqing.Wang@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 7dfc0e2b..41a702db 100644
--- a/tests/amdgpu/basic_tests.c
+++ b/tests/amdgpu/basic_tests.c
@@ -51,6 +51,7 @@ static void amdgpu_userptr_test(void);
static void amdgpu_semaphore_test(void);
static void amdgpu_svm_test(void);
static void amdgpu_multi_svm_test(void);
+static void amdgpu_va_range_test(void);
static void amdgpu_command_submission_write_linear_helper(unsigned ip_type);
static void amdgpu_command_submission_const_fill_helper(unsigned ip_type);
@@ -65,6 +66,7 @@ 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 },
+ { "VA range Test", amdgpu_va_range_test},
{ "SVM Test", amdgpu_svm_test },
{ "SVM Test (multi-GPUs)", amdgpu_multi_svm_test },
CU_TEST_INFO_NULL,
@@ -1453,3 +1455,55 @@ static void amdgpu_multi_svm_test(void)
amdgpu_svm_deinit(device_handles[0]);
}
+
+#define VA_RANGE_TEST_CNT 66
+#define VA_RANGE_TEST_INT_BEL_CNT 20
+#define VA_RANGE_TEST_INT_ABO_CNT 20
+static void amdgpu_va_range_test(void)
+{
+ amdgpu_va_handle va_handles[VA_RANGE_TEST_CNT+VA_RANGE_TEST_INT_BEL_CNT+VA_RANGE_TEST_INT_ABO_CNT];
+ uint64_t va;
+ int i, r;
+
+ printf("\n");
+ printf(" Testing to alloc and free VA in user defined range.\n");
+ memset(va_handles, 0, sizeof(va_handles));
+ for (i = 0; i < VA_RANGE_TEST_CNT; i++) {
+ r = amdgpu_va_range_alloc_in_range(device_handle,
+ amdgpu_gpu_va_range_general,
+ 0x1000000, 9, 0,
+ 0x800000000, 0x840000000,
+ &va, &va_handles[i], 0);
+ printf(" test loop %d, alloc %s\n", i, (r==0)? "success" : "fail");
+ if (!r)
+ printf(" alloc on addr %#llx\n", va);
+ CU_ASSERT_TRUE((r == 0) ||
+ (r && i>=(0x840000000-0x800000000)/0x1000000));
+ }
+ for (i = VA_RANGE_TEST_CNT; i < VA_RANGE_TEST_CNT+VA_RANGE_TEST_INT_BEL_CNT; i++) {
+ r = amdgpu_va_range_alloc_in_range(device_handle,
+ amdgpu_gpu_va_range_general,
+ 0x1000000, 9, 0,
+ 0x600000000, 0x840000000,
+ &va, &va_handles[i], 0);
+ printf(" test loop %d, alloc %s\n", i, (r==0)? "success" : "fail");
+ if (!r)
+ printf(" alloc on addr %#llx\n", va);
+ CU_ASSERT_TRUE (r == 0 && va <=0x800000000);
+ }
+ for (i = VA_RANGE_TEST_CNT+VA_RANGE_TEST_INT_BEL_CNT; i < VA_RANGE_TEST_CNT+VA_RANGE_TEST_INT_BEL_CNT+VA_RANGE_TEST_INT_ABO_CNT; i++) {
+ r = amdgpu_va_range_alloc_in_range(device_handle,
+ amdgpu_gpu_va_range_general,
+ 0x1000000, 9, 0,
+ 0x800000000, 0x940000000,
+ &va, &va_handles[i], 0);
+ printf(" test loop %d, alloc %s\n", i, (r==0)? "success" : "fail");
+ if (!r)
+ printf(" alloc on addr %#llx\n", va);
+ CU_ASSERT_TRUE (r == 0 && va >= 0x840000000);
+ }
+ for (i = 0; i < VA_RANGE_TEST_CNT+VA_RANGE_TEST_INT_BEL_CNT+VA_RANGE_TEST_INT_ABO_CNT; i++) {
+ r = amdgpu_va_range_free(va_handles[i]);
+ CU_ASSERT_EQUAL(r, 0);
+ }
+}