All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zhang, Jerry(Junwei)" <Jerry.Zhang-5C7GfCeVMHo@public.gmane.org>
To: "Christian König"
	<ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH libdrm 3/3] test/amdgpu: add GDS, GWS and OA tests
Date: Tue, 18 Sep 2018 14:09:42 +0800	[thread overview]
Message-ID: <a82279ed-e445-e950-3bfb-a1ae4e62e9aa@amd.com> (raw)
In-Reply-To: <20180914130906.3853-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>

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

  parent reply	other threads:[~2018-09-18  6:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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) [this message]
2018-09-18  6:08   ` [PATCH libdrm 1/3] amdgpu: remove invalid check in amdgpu_bo_alloc Zhang, Jerry(Junwei)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a82279ed-e445-e950-3bfb-a1ae4e62e9aa@amd.com \
    --to=jerry.zhang-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.