<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Series is:</p>
<p style="margin-top:0;margin-bottom:0">Reviewed-by: Alex Deucher <alexander.deucher@amd.com><br>
</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Christian König <ckoenig.leichtzumerken@gmail.com><br>
<b>Sent:</b> Friday, September 14, 2018 9:09:06 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> [PATCH libdrm 3/3] test/amdgpu: add GDS, GWS and OA tests</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Add allocation tests for GDW, GWS and OA.<br>
<br>
Signed-off-by: Christian König <christian.koenig@amd.com><br>
---<br>
 tests/amdgpu/amdgpu_test.h | 48 +++++++++++++++++++++++++---------------------<br>
 tests/amdgpu/bo_tests.c    | 21 ++++++++++++++++++++<br>
 2 files changed, 47 insertions(+), 22 deletions(-)<br>
<br>
diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h<br>
index d1e14e23..af3041e5 100644<br>
--- a/tests/amdgpu/amdgpu_test.h<br>
+++ b/tests/amdgpu/amdgpu_test.h<br>
@@ -207,11 +207,9 @@ static inline amdgpu_bo_handle gpu_mem_alloc(<br>
                                         amdgpu_va_handle *va_handle)<br>
 {<br>
         struct amdgpu_bo_alloc_request req = {0};<br>
-       amdgpu_bo_handle buf_handle;<br>
+       amdgpu_bo_handle buf_handle = NULL;<br>
         int r;<br>
 <br>
-       CU_ASSERT_NOT_EQUAL(vmc_addr, NULL);<br>
-<br>
         req.alloc_size = size;<br>
         req.phys_alignment = alignment;<br>
         req.preferred_heap = type;<br>
@@ -222,16 +220,19 @@ static inline amdgpu_bo_handle gpu_mem_alloc(<br>
         if (r)<br>
                 return NULL;<br>
 <br>
-       r = amdgpu_va_range_alloc(device_handle,<br>
-                                 amdgpu_gpu_va_range_general,<br>
-                                 size, alignment, 0, vmc_addr,<br>
-                                 va_handle, 0);<br>
-       CU_ASSERT_EQUAL(r, 0);<br>
-       if (r)<br>
-               goto error_free_bo;<br>
-<br>
-       r = amdgpu_bo_va_op(buf_handle, 0, size, *vmc_addr, 0, AMDGPU_VA_OP_MAP);<br>
-       CU_ASSERT_EQUAL(r, 0);<br>
+       if (vmc_addr && va_handle) {<br>
+               r = amdgpu_va_range_alloc(device_handle,<br>
+                                         amdgpu_gpu_va_range_general,<br>
+                                         size, alignment, 0, vmc_addr,<br>
+                                         va_handle, 0);<br>
+               CU_ASSERT_EQUAL(r, 0);<br>
+               if (r)<br>
+                       goto error_free_bo;<br>
+<br>
+               r = amdgpu_bo_va_op(buf_handle, 0, size, *vmc_addr, 0,<br>
+                                   AMDGPU_VA_OP_MAP);<br>
+               CU_ASSERT_EQUAL(r, 0);<br>
+       }<br>
 <br>
         return buf_handle;<br>
 <br>
@@ -256,15 +257,18 @@ static inline int gpu_mem_free(amdgpu_bo_handle bo,<br>
         if (!bo)<br>
                 return 0;<br>
 <br>
-       r = amdgpu_bo_va_op(bo, 0, size, vmc_addr, 0, AMDGPU_VA_OP_UNMAP);<br>
-       CU_ASSERT_EQUAL(r, 0);<br>
-       if (r)<br>
-               return r;<br>
-<br>
-       r = amdgpu_va_range_free(va_handle);<br>
-       CU_ASSERT_EQUAL(r, 0);<br>
-       if (r)<br>
-               return r;<br>
+       if (va_handle) {<br>
+               r = amdgpu_bo_va_op(bo, 0, size, vmc_addr, 0,<br>
+                                   AMDGPU_VA_OP_UNMAP);<br>
+               CU_ASSERT_EQUAL(r, 0);<br>
+               if (r)<br>
+                       return r;<br>
+<br>
+               r = amdgpu_va_range_free(va_handle);<br>
+               CU_ASSERT_EQUAL(r, 0);<br>
+               if (r)<br>
+                       return r;<br>
+       }<br>
 <br>
         r = amdgpu_bo_free(bo);<br>
         CU_ASSERT_EQUAL(r, 0);<br>
diff --git a/tests/amdgpu/bo_tests.c b/tests/amdgpu/bo_tests.c<br>
index dc2de9b7..7cff4cf7 100644<br>
--- a/tests/amdgpu/bo_tests.c<br>
+++ b/tests/amdgpu/bo_tests.c<br>
@@ -242,6 +242,27 @@ static void amdgpu_memory_alloc(void)<br>
 <br>
         r = gpu_mem_free(bo, va_handle, bo_mc, 4096);<br>
         CU_ASSERT_EQUAL(r, 0);<br>
+<br>
+       /* Test GDS */<br>
+       bo = gpu_mem_alloc(device_handle, 1024, 0,<br>
+                       AMDGPU_GEM_DOMAIN_GDS, 0,<br>
+                       NULL, NULL);<br>
+       r = gpu_mem_free(bo, NULL, 0, 4096);<br>
+       CU_ASSERT_EQUAL(r, 0);<br>
+<br>
+       /* Test GWS */<br>
+       bo = gpu_mem_alloc(device_handle, 1, 0,<br>
+                       AMDGPU_GEM_DOMAIN_GWS, 0,<br>
+                       NULL, NULL);<br>
+       r = gpu_mem_free(bo, NULL, 0, 4096);<br>
+       CU_ASSERT_EQUAL(r, 0);<br>
+<br>
+       /* Test OA */<br>
+       bo = gpu_mem_alloc(device_handle, 1, 0,<br>
+                       AMDGPU_GEM_DOMAIN_OA, 0,<br>
+                       NULL, NULL);<br>
+       r = gpu_mem_free(bo, NULL, 0, 4096);<br>
+       CU_ASSERT_EQUAL(r, 0);<br>
 }<br>
 <br>
 static void amdgpu_mem_fail_alloc(void)<br>
-- <br>
2.14.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
</div>
</span></font></div>
</body>
</html>