All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH libdrm] amdgpu: add PRT unit test
Date: Wed,  8 Feb 2017 16:06:26 +0100	[thread overview]
Message-ID: <1486566386-3591-1-git-send-email-deathsimple@vodafone.de> (raw)

From: Christian König <christian.koenig@amd.com>

Just a simple test if PRT works or not.

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

diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c
index bfda21b..24dd605 100644
--- a/tests/amdgpu/basic_tests.c
+++ b/tests/amdgpu/basic_tests.c
@@ -48,6 +48,7 @@ static void amdgpu_command_submission_compute(void);
 static void amdgpu_command_submission_sdma(void);
 static void amdgpu_userptr_test(void);
 static void amdgpu_semaphore_test(void);
+static void amdgpu_prt_test(void);
 
 static void amdgpu_command_submission_write_linear_helper(unsigned ip_type);
 static void amdgpu_command_submission_const_fill_helper(unsigned ip_type);
@@ -61,6 +62,7 @@ CU_TestInfo basic_tests[] = {
 	{ "Command submission Test (Compute)", amdgpu_command_submission_compute },
 	{ "Command submission Test (SDMA)", amdgpu_command_submission_sdma },
 	{ "SW semaphore Test",  amdgpu_semaphore_test },
+	{ "PRT Test",  amdgpu_prt_test },
 	CU_TEST_INFO_NULL,
 };
 #define BUFFER_SIZE (8 * 1024)
@@ -734,7 +736,6 @@ static void amdgpu_test_exec_cs_helper(amdgpu_context_handle context_handle,
 
 	/* prepare CS */
 	CU_ASSERT_NOT_EQUAL(pm4_src, NULL);
-	CU_ASSERT_NOT_EQUAL(resources, NULL);
 	CU_ASSERT_NOT_EQUAL(ib_info, NULL);
 	CU_ASSERT_NOT_EQUAL(ibs_request, NULL);
 	CU_ASSERT_TRUE(pm4_dw <= 1024);
@@ -759,7 +760,8 @@ static void amdgpu_test_exec_cs_helper(amdgpu_context_handle context_handle,
 	ibs_request->ibs = ib_info;
 	ibs_request->fence_info.handle = NULL;
 
-	memcpy(all_res, resources, sizeof(resources[0]) * res_cnt);
+	if (resources)
+		memcpy(all_res, resources, sizeof(resources[0]) * res_cnt);
 	all_res[res_cnt] = ib_result_handle;
 
 	r = amdgpu_bo_list_create(device_handle, res_cnt+1, all_res,
@@ -1208,3 +1210,63 @@ static void amdgpu_userptr_test(void)
 	r = amdgpu_cs_ctx_free(context_handle);
 	CU_ASSERT_EQUAL(r, 0);
 }
+
+static void amdgpu_prt_test(void)
+{
+	int i, r, j;
+	uint32_t *pm4 = NULL;
+	uint64_t bo_mc;
+	int pm4_dw = 256;
+	int sdma_write_length = 4;
+	amdgpu_context_handle context_handle;
+	struct amdgpu_cs_ib_info *ib_info;
+	struct amdgpu_cs_request *ibs_request;
+	amdgpu_va_handle va_handle;
+
+	pm4 = calloc(pm4_dw, sizeof(*pm4));
+	CU_ASSERT_NOT_EQUAL(pm4, NULL);
+
+	ib_info = calloc(1, sizeof(*ib_info));
+	CU_ASSERT_NOT_EQUAL(ib_info, NULL);
+
+	ibs_request = calloc(1, sizeof(*ibs_request));
+	CU_ASSERT_NOT_EQUAL(ibs_request, NULL);
+
+	r = amdgpu_cs_ctx_create(device_handle, &context_handle);
+	CU_ASSERT_EQUAL(r, 0);
+
+	r = amdgpu_va_range_alloc(device_handle,
+				  amdgpu_gpu_va_range_general,
+				  BUFFER_SIZE, 1, 0, &bo_mc,
+				  &va_handle, 0);
+	CU_ASSERT_EQUAL(r, 0);
+
+	/*r = amdgpu_bo_va_op_raw(device_handle, NULL, 0, BUFFER_SIZE, bo_mc,
+				AMDGPU_VM_PAGE_PRT, AMDGPU_VA_OP_MAP);
+	CU_ASSERT_EQUAL(r, 0);*/
+
+	j = i = 0;
+	pm4[i++] = PACKET3(PACKET3_WRITE_DATA, 2 + sdma_write_length);
+	pm4[i++] = WRITE_DATA_DST_SEL(5) | WR_CONFIRM;
+	pm4[i++] = 0xfffffffc & bo_mc;
+	pm4[i++] = (0xffffffff00000000 & bo_mc) >> 32;
+	while(j++ < sdma_write_length)
+		pm4[i++] = 0xdeadbeaf;
+
+	amdgpu_test_exec_cs_helper(context_handle,
+				   AMDGPU_HW_IP_GFX, 0,
+				   i, pm4, 0, NULL,
+				   ib_info, ibs_request);
+	free(ibs_request);
+	free(ib_info);
+	free(pm4);
+
+	r = amdgpu_bo_va_op_raw(device_handle, NULL, 0, BUFFER_SIZE, bo_mc,
+				AMDGPU_VM_PAGE_PRT, AMDGPU_VA_OP_UNMAP);
+	CU_ASSERT_EQUAL(r, 0);
+	r = amdgpu_va_range_free(va_handle);
+	CU_ASSERT_EQUAL(r, 0);
+
+	r = amdgpu_cs_ctx_free(context_handle);
+	CU_ASSERT_EQUAL(r, 0);
+}
-- 
2.5.0

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

             reply	other threads:[~2017-02-08 15:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-08 15:06 Christian König [this message]
     [not found] ` <1486566386-3591-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-02-08 16:49   ` [PATCH libdrm] amdgpu: add PRT unit test Nicolai Hähnle

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=1486566386-3591-1-git-send-email-deathsimple@vodafone.de \
    --to=deathsimple-antagkrnahcb1svskn2v4q@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@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.