All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH libdrm 1/3] amdgpu: remove invalid check in amdgpu_bo_alloc
@ 2018-09-14 13:09 Christian König
       [not found] ` <20180914130906.3853-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Christian König @ 2018-09-14 13:09 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

The heap is checked by the kernel and not libdrm, to make it even worse
it prevented allocating resources other than VRAM and GTT.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 amdgpu/amdgpu_bo.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
index 6a95929c..34904e38 100644
--- a/amdgpu/amdgpu_bo.c
+++ b/amdgpu/amdgpu_bo.c
@@ -74,19 +74,14 @@ int amdgpu_bo_alloc(amdgpu_device_handle dev,
 		    amdgpu_bo_handle *buf_handle)
 {
 	union drm_amdgpu_gem_create args;
-	unsigned heap = alloc_buffer->preferred_heap;
-	int r = 0;
-
-	/* It's an error if the heap is not specified */
-	if (!(heap & (AMDGPU_GEM_DOMAIN_GTT | AMDGPU_GEM_DOMAIN_VRAM)))
-		return -EINVAL;
+	int r;
 
 	memset(&args, 0, sizeof(args));
 	args.in.bo_size = alloc_buffer->alloc_size;
 	args.in.alignment = alloc_buffer->phys_alignment;
 
 	/* Set the placement. */
-	args.in.domains = heap;
+	args.in.domains = alloc_buffer->preferred_heap;
 	args.in.domain_flags = alloc_buffer->flags;
 
 	/* Allocate the buffer with the preferred heap. */
-- 
2.14.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH libdrm 2/3] test/amdgpu: add proper error handling
       [not found] ` <20180914130906.3853-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
@ 2018-09-14 13:09   ` Christian König
       [not found]     ` <20180914130906.3853-2-christian.koenig-5C7GfCeVMHo@public.gmane.org>
  2018-09-14 13:09   ` [PATCH libdrm 3/3] test/amdgpu: add GDS, GWS and OA tests Christian König
  2018-09-18  6:08   ` [PATCH libdrm 1/3] amdgpu: remove invalid check in amdgpu_bo_alloc Zhang, Jerry(Junwei)
  2 siblings, 1 reply; 7+ messages in thread
From: Christian König @ 2018-09-14 13:09 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Otherwise the calling function won't notice that something is wrong.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 tests/amdgpu/amdgpu_test.h | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h
index f2ece3c3..d1e14e23 100644
--- a/tests/amdgpu/amdgpu_test.h
+++ b/tests/amdgpu/amdgpu_test.h
@@ -219,17 +219,31 @@ static inline amdgpu_bo_handle gpu_mem_alloc(
 
 	r = amdgpu_bo_alloc(device_handle, &req, &buf_handle);
 	CU_ASSERT_EQUAL(r, 0);
+	if (r)
+		return NULL;
 
 	r = amdgpu_va_range_alloc(device_handle,
 				  amdgpu_gpu_va_range_general,
 				  size, alignment, 0, vmc_addr,
 				  va_handle, 0);
 	CU_ASSERT_EQUAL(r, 0);
+	if (r)
+		goto error_free_bo;
 
 	r = amdgpu_bo_va_op(buf_handle, 0, size, *vmc_addr, 0, AMDGPU_VA_OP_MAP);
 	CU_ASSERT_EQUAL(r, 0);
 
 	return buf_handle;
+
+error_free_va:
+	r = amdgpu_va_range_free(*va_handle);
+	CU_ASSERT_EQUAL(r, 0);
+
+error_free_bo:
+	r = amdgpu_bo_free(buf_handle);
+	CU_ASSERT_EQUAL(r, 0);
+
+	return NULL;
 }
 
 static inline int gpu_mem_free(amdgpu_bo_handle bo,
@@ -239,16 +253,23 @@ static inline int gpu_mem_free(amdgpu_bo_handle bo,
 {
 	int r;
 
+	if (!bo)
+		return 0;
+
 	r = amdgpu_bo_va_op(bo, 0, size, vmc_addr, 0, AMDGPU_VA_OP_UNMAP);
 	CU_ASSERT_EQUAL(r, 0);
+	if (r)
+		return r;
 
 	r = amdgpu_va_range_free(va_handle);
 	CU_ASSERT_EQUAL(r, 0);
+	if (r)
+		return r;
 
 	r = amdgpu_bo_free(bo);
 	CU_ASSERT_EQUAL(r, 0);
 
-	return 0;
+	return r;
 }
 
 static inline int
-- 
2.14.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH libdrm 3/3] test/amdgpu: add GDS, GWS and OA tests
       [not found] ` <20180914130906.3853-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
  2018-09-14 13:09   ` [PATCH libdrm 2/3] test/amdgpu: add proper error handling Christian König
@ 2018-09-14 13:09   ` Christian König
       [not found]     ` <20180914130906.3853-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>
  2018-09-18  6:08   ` [PATCH libdrm 1/3] amdgpu: remove invalid check in amdgpu_bo_alloc Zhang, Jerry(Junwei)
  2 siblings, 1 reply; 7+ messages in thread
From: Christian König @ 2018-09-14 13:09 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Add allocation tests for GDW, GWS and OA.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 tests/amdgpu/amdgpu_test.h | 48 +++++++++++++++++++++++++---------------------
 tests/amdgpu/bo_tests.c    | 21 ++++++++++++++++++++
 2 files changed, 47 insertions(+), 22 deletions(-)

diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h
index d1e14e23..af3041e5 100644
--- a/tests/amdgpu/amdgpu_test.h
+++ b/tests/amdgpu/amdgpu_test.h
@@ -207,11 +207,9 @@ static inline amdgpu_bo_handle gpu_mem_alloc(
 					amdgpu_va_handle *va_handle)
 {
 	struct amdgpu_bo_alloc_request req = {0};
-	amdgpu_bo_handle buf_handle;
+	amdgpu_bo_handle buf_handle = NULL;
 	int r;
 
-	CU_ASSERT_NOT_EQUAL(vmc_addr, NULL);
-
 	req.alloc_size = size;
 	req.phys_alignment = alignment;
 	req.preferred_heap = type;
@@ -222,16 +220,19 @@ static inline amdgpu_bo_handle gpu_mem_alloc(
 	if (r)
 		return NULL;
 
-	r = amdgpu_va_range_alloc(device_handle,
-				  amdgpu_gpu_va_range_general,
-				  size, alignment, 0, vmc_addr,
-				  va_handle, 0);
-	CU_ASSERT_EQUAL(r, 0);
-	if (r)
-		goto error_free_bo;
-
-	r = amdgpu_bo_va_op(buf_handle, 0, size, *vmc_addr, 0, AMDGPU_VA_OP_MAP);
-	CU_ASSERT_EQUAL(r, 0);
+	if (vmc_addr && va_handle) {
+		r = amdgpu_va_range_alloc(device_handle,
+					  amdgpu_gpu_va_range_general,
+					  size, alignment, 0, vmc_addr,
+					  va_handle, 0);
+		CU_ASSERT_EQUAL(r, 0);
+		if (r)
+			goto error_free_bo;
+
+		r = amdgpu_bo_va_op(buf_handle, 0, size, *vmc_addr, 0,
+				    AMDGPU_VA_OP_MAP);
+		CU_ASSERT_EQUAL(r, 0);
+	}
 
 	return buf_handle;
 
@@ -256,15 +257,18 @@ static inline int gpu_mem_free(amdgpu_bo_handle bo,
 	if (!bo)
 		return 0;
 
-	r = amdgpu_bo_va_op(bo, 0, size, vmc_addr, 0, AMDGPU_VA_OP_UNMAP);
-	CU_ASSERT_EQUAL(r, 0);
-	if (r)
-		return r;
-
-	r = amdgpu_va_range_free(va_handle);
-	CU_ASSERT_EQUAL(r, 0);
-	if (r)
-		return r;
+	if (va_handle) {
+		r = amdgpu_bo_va_op(bo, 0, size, vmc_addr, 0,
+				    AMDGPU_VA_OP_UNMAP);
+		CU_ASSERT_EQUAL(r, 0);
+		if (r)
+			return r;
+
+		r = amdgpu_va_range_free(va_handle);
+		CU_ASSERT_EQUAL(r, 0);
+		if (r)
+			return r;
+	}
 
 	r = amdgpu_bo_free(bo);
 	CU_ASSERT_EQUAL(r, 0);
diff --git a/tests/amdgpu/bo_tests.c b/tests/amdgpu/bo_tests.c
index dc2de9b7..7cff4cf7 100644
--- a/tests/amdgpu/bo_tests.c
+++ b/tests/amdgpu/bo_tests.c
@@ -242,6 +242,27 @@ static void amdgpu_memory_alloc(void)
 
 	r = gpu_mem_free(bo, va_handle, bo_mc, 4096);
 	CU_ASSERT_EQUAL(r, 0);
+
+	/* Test GDS */
+	bo = gpu_mem_alloc(device_handle, 1024, 0,
+			AMDGPU_GEM_DOMAIN_GDS, 0,
+			NULL, NULL);
+	r = gpu_mem_free(bo, NULL, 0, 4096);
+	CU_ASSERT_EQUAL(r, 0);
+
+	/* Test GWS */
+	bo = gpu_mem_alloc(device_handle, 1, 0,
+			AMDGPU_GEM_DOMAIN_GWS, 0,
+			NULL, NULL);
+	r = gpu_mem_free(bo, NULL, 0, 4096);
+	CU_ASSERT_EQUAL(r, 0);
+
+	/* Test OA */
+	bo = gpu_mem_alloc(device_handle, 1, 0,
+			AMDGPU_GEM_DOMAIN_OA, 0,
+			NULL, NULL);
+	r = gpu_mem_free(bo, NULL, 0, 4096);
+	CU_ASSERT_EQUAL(r, 0);
 }
 
 static void amdgpu_mem_fail_alloc(void)
-- 
2.14.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH libdrm 3/3] test/amdgpu: add GDS, GWS and OA tests
       [not found]     ` <20180914130906.3853-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>
@ 2018-09-14 13:54       ` Deucher, Alexander
  2018-09-18  6:09       ` Zhang, Jerry(Junwei)
  1 sibling, 0 replies; 7+ messages in thread
From: Deucher, Alexander @ 2018-09-14 13:54 UTC (permalink / raw)
  To: Christian König, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW


[-- Attachment #1.1: Type: text/plain, Size: 4774 bytes --]

Series is:

Reviewed-by: Alex Deucher <alexander.deucher-5C7GfCeVMHo@public.gmane.org>

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Christian König <ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Sent: Friday, September 14, 2018 9:09:06 AM
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH libdrm 3/3] test/amdgpu: add GDS, GWS and OA tests

Add allocation tests for GDW, GWS and OA.

Signed-off-by: Christian König <christian.koenig-5C7GfCeVMHo@public.gmane.org>
---
 tests/amdgpu/amdgpu_test.h | 48 +++++++++++++++++++++++++---------------------
 tests/amdgpu/bo_tests.c    | 21 ++++++++++++++++++++
 2 files changed, 47 insertions(+), 22 deletions(-)

diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h
index d1e14e23..af3041e5 100644
--- a/tests/amdgpu/amdgpu_test.h
+++ b/tests/amdgpu/amdgpu_test.h
@@ -207,11 +207,9 @@ static inline amdgpu_bo_handle gpu_mem_alloc(
                                         amdgpu_va_handle *va_handle)
 {
         struct amdgpu_bo_alloc_request req = {0};
-       amdgpu_bo_handle buf_handle;
+       amdgpu_bo_handle buf_handle = NULL;
         int r;

-       CU_ASSERT_NOT_EQUAL(vmc_addr, NULL);
-
         req.alloc_size = size;
         req.phys_alignment = alignment;
         req.preferred_heap = type;
@@ -222,16 +220,19 @@ static inline amdgpu_bo_handle gpu_mem_alloc(
         if (r)
                 return NULL;

-       r = amdgpu_va_range_alloc(device_handle,
-                                 amdgpu_gpu_va_range_general,
-                                 size, alignment, 0, vmc_addr,
-                                 va_handle, 0);
-       CU_ASSERT_EQUAL(r, 0);
-       if (r)
-               goto error_free_bo;
-
-       r = amdgpu_bo_va_op(buf_handle, 0, size, *vmc_addr, 0, AMDGPU_VA_OP_MAP);
-       CU_ASSERT_EQUAL(r, 0);
+       if (vmc_addr && va_handle) {
+               r = amdgpu_va_range_alloc(device_handle,
+                                         amdgpu_gpu_va_range_general,
+                                         size, alignment, 0, vmc_addr,
+                                         va_handle, 0);
+               CU_ASSERT_EQUAL(r, 0);
+               if (r)
+                       goto error_free_bo;
+
+               r = amdgpu_bo_va_op(buf_handle, 0, size, *vmc_addr, 0,
+                                   AMDGPU_VA_OP_MAP);
+               CU_ASSERT_EQUAL(r, 0);
+       }

         return buf_handle;

@@ -256,15 +257,18 @@ static inline int gpu_mem_free(amdgpu_bo_handle bo,
         if (!bo)
                 return 0;

-       r = amdgpu_bo_va_op(bo, 0, size, vmc_addr, 0, AMDGPU_VA_OP_UNMAP);
-       CU_ASSERT_EQUAL(r, 0);
-       if (r)
-               return r;
-
-       r = amdgpu_va_range_free(va_handle);
-       CU_ASSERT_EQUAL(r, 0);
-       if (r)
-               return r;
+       if (va_handle) {
+               r = amdgpu_bo_va_op(bo, 0, size, vmc_addr, 0,
+                                   AMDGPU_VA_OP_UNMAP);
+               CU_ASSERT_EQUAL(r, 0);
+               if (r)
+                       return r;
+
+               r = amdgpu_va_range_free(va_handle);
+               CU_ASSERT_EQUAL(r, 0);
+               if (r)
+                       return r;
+       }

         r = amdgpu_bo_free(bo);
         CU_ASSERT_EQUAL(r, 0);
diff --git a/tests/amdgpu/bo_tests.c b/tests/amdgpu/bo_tests.c
index dc2de9b7..7cff4cf7 100644
--- a/tests/amdgpu/bo_tests.c
+++ b/tests/amdgpu/bo_tests.c
@@ -242,6 +242,27 @@ static void amdgpu_memory_alloc(void)

         r = gpu_mem_free(bo, va_handle, bo_mc, 4096);
         CU_ASSERT_EQUAL(r, 0);
+
+       /* Test GDS */
+       bo = gpu_mem_alloc(device_handle, 1024, 0,
+                       AMDGPU_GEM_DOMAIN_GDS, 0,
+                       NULL, NULL);
+       r = gpu_mem_free(bo, NULL, 0, 4096);
+       CU_ASSERT_EQUAL(r, 0);
+
+       /* Test GWS */
+       bo = gpu_mem_alloc(device_handle, 1, 0,
+                       AMDGPU_GEM_DOMAIN_GWS, 0,
+                       NULL, NULL);
+       r = gpu_mem_free(bo, NULL, 0, 4096);
+       CU_ASSERT_EQUAL(r, 0);
+
+       /* Test OA */
+       bo = gpu_mem_alloc(device_handle, 1, 0,
+                       AMDGPU_GEM_DOMAIN_OA, 0,
+                       NULL, NULL);
+       r = gpu_mem_free(bo, NULL, 0, 4096);
+       CU_ASSERT_EQUAL(r, 0);
 }

 static void amdgpu_mem_fail_alloc(void)
--
2.14.1

_______________________________________________
amd-gfx mailing list
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[-- Attachment #1.2: Type: text/html, Size: 11780 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH libdrm 2/3] test/amdgpu: add proper error handling
       [not found]     ` <20180914130906.3853-2-christian.koenig-5C7GfCeVMHo@public.gmane.org>
@ 2018-09-18  6:07       ` Zhang, Jerry(Junwei)
  0 siblings, 0 replies; 7+ messages in thread
From: Zhang, Jerry(Junwei) @ 2018-09-18  6:07 UTC (permalink / raw)
  To: Christian König, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On 09/14/2018 09:09 PM, Christian König wrote:
> Otherwise the calling function won't notice that something is wrong.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>   tests/amdgpu/amdgpu_test.h | 23 ++++++++++++++++++++++-
>   1 file changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h
> index f2ece3c3..d1e14e23 100644
> --- a/tests/amdgpu/amdgpu_test.h
> +++ b/tests/amdgpu/amdgpu_test.h
> @@ -219,17 +219,31 @@ static inline amdgpu_bo_handle gpu_mem_alloc(
>   
>   	r = amdgpu_bo_alloc(device_handle, &req, &buf_handle);
>   	CU_ASSERT_EQUAL(r, 0);
> +	if (r)
> +		return NULL;
>   
>   	r = amdgpu_va_range_alloc(device_handle,
>   				  amdgpu_gpu_va_range_general,
>   				  size, alignment, 0, vmc_addr,
>   				  va_handle, 0);
>   	CU_ASSERT_EQUAL(r, 0);
> +	if (r)
> +		goto error_free_bo;
>   
>   	r = amdgpu_bo_va_op(buf_handle, 0, size, *vmc_addr, 0, AMDGPU_VA_OP_MAP);
>   	CU_ASSERT_EQUAL(r, 0);

We may also add error check for bo map.

Regards,
Jerry
>   
>   	return buf_handle;
> +
> +error_free_va:
> +	r = amdgpu_va_range_free(*va_handle);
> +	CU_ASSERT_EQUAL(r, 0);
> +
> +error_free_bo:
> +	r = amdgpu_bo_free(buf_handle);
> +	CU_ASSERT_EQUAL(r, 0);
> +
> +	return NULL;
>   }
>   
>   static inline int gpu_mem_free(amdgpu_bo_handle bo,
> @@ -239,16 +253,23 @@ static inline int gpu_mem_free(amdgpu_bo_handle bo,
>   {
>   	int r;
>   
> +	if (!bo)
> +		return 0;
> +
>   	r = amdgpu_bo_va_op(bo, 0, size, vmc_addr, 0, AMDGPU_VA_OP_UNMAP);
>   	CU_ASSERT_EQUAL(r, 0);
> +	if (r)
> +		return r;
>   
>   	r = amdgpu_va_range_free(va_handle);
>   	CU_ASSERT_EQUAL(r, 0);
> +	if (r)
> +		return r;
>   
>   	r = amdgpu_bo_free(bo);
>   	CU_ASSERT_EQUAL(r, 0);
>   
> -	return 0;
> +	return r;
>   }
>   
>   static inline int

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH libdrm 1/3] amdgpu: remove invalid check in amdgpu_bo_alloc
       [not found] ` <20180914130906.3853-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
  2018-09-14 13:09   ` [PATCH libdrm 2/3] test/amdgpu: add proper error handling Christian König
  2018-09-14 13:09   ` [PATCH libdrm 3/3] test/amdgpu: add GDS, GWS and OA tests Christian König
@ 2018-09-18  6:08   ` Zhang, Jerry(Junwei)
  2 siblings, 0 replies; 7+ messages in thread
From: Zhang, Jerry(Junwei) @ 2018-09-18  6:08 UTC (permalink / raw)
  To: Christian König, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On 09/14/2018 09:09 PM, Christian König wrote:
> The heap is checked by the kernel and not libdrm, to make it even worse
> it prevented allocating resources other than VRAM and GTT.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>

> ---
>   amdgpu/amdgpu_bo.c | 9 ++-------
>   1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
> index 6a95929c..34904e38 100644
> --- a/amdgpu/amdgpu_bo.c
> +++ b/amdgpu/amdgpu_bo.c
> @@ -74,19 +74,14 @@ int amdgpu_bo_alloc(amdgpu_device_handle dev,
>   		    amdgpu_bo_handle *buf_handle)
>   {
>   	union drm_amdgpu_gem_create args;
> -	unsigned heap = alloc_buffer->preferred_heap;
> -	int r = 0;
> -
> -	/* It's an error if the heap is not specified */
> -	if (!(heap & (AMDGPU_GEM_DOMAIN_GTT | AMDGPU_GEM_DOMAIN_VRAM)))
> -		return -EINVAL;
> +	int r;
>   
>   	memset(&args, 0, sizeof(args));
>   	args.in.bo_size = alloc_buffer->alloc_size;
>   	args.in.alignment = alloc_buffer->phys_alignment;
>   
>   	/* Set the placement. */
> -	args.in.domains = heap;
> +	args.in.domains = alloc_buffer->preferred_heap;
>   	args.in.domain_flags = alloc_buffer->flags;
>   
>   	/* Allocate the buffer with the preferred heap. */

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH libdrm 3/3] test/amdgpu: add GDS, GWS and OA tests
       [not found]     ` <20180914130906.3853-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>
  2018-09-14 13:54       ` Deucher, Alexander
@ 2018-09-18  6:09       ` Zhang, Jerry(Junwei)
  1 sibling, 0 replies; 7+ messages in thread
From: Zhang, Jerry(Junwei) @ 2018-09-18  6:09 UTC (permalink / raw)
  To: Christian König, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On 09/14/2018 09:09 PM, Christian König wrote:
> Add allocation tests for GDW, GWS and OA.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>   tests/amdgpu/amdgpu_test.h | 48 +++++++++++++++++++++++++---------------------
>   tests/amdgpu/bo_tests.c    | 21 ++++++++++++++++++++
>   2 files changed, 47 insertions(+), 22 deletions(-)
>
> diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h
> index d1e14e23..af3041e5 100644
> --- a/tests/amdgpu/amdgpu_test.h
> +++ b/tests/amdgpu/amdgpu_test.h
> @@ -207,11 +207,9 @@ static inline amdgpu_bo_handle gpu_mem_alloc(
>   					amdgpu_va_handle *va_handle)
>   {
>   	struct amdgpu_bo_alloc_request req = {0};
> -	amdgpu_bo_handle buf_handle;
> +	amdgpu_bo_handle buf_handle = NULL;
>   	int r;
>   
> -	CU_ASSERT_NOT_EQUAL(vmc_addr, NULL);
> -
>   	req.alloc_size = size;
>   	req.phys_alignment = alignment;
>   	req.preferred_heap = type;
> @@ -222,16 +220,19 @@ static inline amdgpu_bo_handle gpu_mem_alloc(
>   	if (r)
>   		return NULL;
>   
> -	r = amdgpu_va_range_alloc(device_handle,
> -				  amdgpu_gpu_va_range_general,
> -				  size, alignment, 0, vmc_addr,
> -				  va_handle, 0);
> -	CU_ASSERT_EQUAL(r, 0);
> -	if (r)
> -		goto error_free_bo;
> -
> -	r = amdgpu_bo_va_op(buf_handle, 0, size, *vmc_addr, 0, AMDGPU_VA_OP_MAP);
> -	CU_ASSERT_EQUAL(r, 0);
> +	if (vmc_addr && va_handle) {
> +		r = amdgpu_va_range_alloc(device_handle,
> +					  amdgpu_gpu_va_range_general,
> +					  size, alignment, 0, vmc_addr,
> +					  va_handle, 0);
> +		CU_ASSERT_EQUAL(r, 0);
> +		if (r)
> +			goto error_free_bo;
> +
> +		r = amdgpu_bo_va_op(buf_handle, 0, size, *vmc_addr, 0,
> +				    AMDGPU_VA_OP_MAP);
> +		CU_ASSERT_EQUAL(r, 0);

Error check for bo map here as well.

Regards,
Jerry
> +	}
>   
>   	return buf_handle;
>   
> @@ -256,15 +257,18 @@ static inline int gpu_mem_free(amdgpu_bo_handle bo,
>   	if (!bo)
>   		return 0;
>   
> -	r = amdgpu_bo_va_op(bo, 0, size, vmc_addr, 0, AMDGPU_VA_OP_UNMAP);
> -	CU_ASSERT_EQUAL(r, 0);
> -	if (r)
> -		return r;
> -
> -	r = amdgpu_va_range_free(va_handle);
> -	CU_ASSERT_EQUAL(r, 0);
> -	if (r)
> -		return r;
> +	if (va_handle) {
> +		r = amdgpu_bo_va_op(bo, 0, size, vmc_addr, 0,
> +				    AMDGPU_VA_OP_UNMAP);
> +		CU_ASSERT_EQUAL(r, 0);
> +		if (r)
> +			return r;
> +
> +		r = amdgpu_va_range_free(va_handle);
> +		CU_ASSERT_EQUAL(r, 0);
> +		if (r)
> +			return r;
> +	}
>   
>   	r = amdgpu_bo_free(bo);
>   	CU_ASSERT_EQUAL(r, 0);
> diff --git a/tests/amdgpu/bo_tests.c b/tests/amdgpu/bo_tests.c
> index dc2de9b7..7cff4cf7 100644
> --- a/tests/amdgpu/bo_tests.c
> +++ b/tests/amdgpu/bo_tests.c
> @@ -242,6 +242,27 @@ static void amdgpu_memory_alloc(void)
>   
>   	r = gpu_mem_free(bo, va_handle, bo_mc, 4096);
>   	CU_ASSERT_EQUAL(r, 0);
> +
> +	/* Test GDS */
> +	bo = gpu_mem_alloc(device_handle, 1024, 0,
> +			AMDGPU_GEM_DOMAIN_GDS, 0,
> +			NULL, NULL);
> +	r = gpu_mem_free(bo, NULL, 0, 4096);
> +	CU_ASSERT_EQUAL(r, 0);
> +
> +	/* Test GWS */
> +	bo = gpu_mem_alloc(device_handle, 1, 0,
> +			AMDGPU_GEM_DOMAIN_GWS, 0,
> +			NULL, NULL);
> +	r = gpu_mem_free(bo, NULL, 0, 4096);
> +	CU_ASSERT_EQUAL(r, 0);
> +
> +	/* Test OA */
> +	bo = gpu_mem_alloc(device_handle, 1, 0,
> +			AMDGPU_GEM_DOMAIN_OA, 0,
> +			NULL, NULL);
> +	r = gpu_mem_free(bo, NULL, 0, 4096);
> +	CU_ASSERT_EQUAL(r, 0);
>   }
>   
>   static void amdgpu_mem_fail_alloc(void)

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-09-18  6:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-14 13:09 [PATCH libdrm 1/3] amdgpu: remove invalid check in amdgpu_bo_alloc Christian König
     [not found] ` <20180914130906.3853-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-09-14 13:09   ` [PATCH libdrm 2/3] test/amdgpu: add proper error handling Christian König
     [not found]     ` <20180914130906.3853-2-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-09-18  6:07       ` Zhang, Jerry(Junwei)
2018-09-14 13:09   ` [PATCH libdrm 3/3] test/amdgpu: add GDS, GWS and OA tests Christian König
     [not found]     ` <20180914130906.3853-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-09-14 13:54       ` Deucher, Alexander
2018-09-18  6:09       ` Zhang, Jerry(Junwei)
2018-09-18  6:08   ` [PATCH libdrm 1/3] amdgpu: remove invalid check in amdgpu_bo_alloc Zhang, Jerry(Junwei)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.