From: Chunming Zhou <David1.Zhou-5C7GfCeVMHo@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Chunming Zhou <David1.Zhou-5C7GfCeVMHo@public.gmane.org>,
David.Mao-5C7GfCeVMHo@public.gmane.org
Subject: [PATCH 4/4] tests/amdgpu: add semaphore across process test
Date: Thu, 18 Aug 2016 15:55:59 +0800 [thread overview]
Message-ID: <1471506959-905-5-git-send-email-David1.Zhou@amd.com> (raw)
In-Reply-To: <1471506959-905-1-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
Change-Id: I6e8c8cfa1a05f51f3c03670baea68ed6da94fa11
Signed-off-by: Chunming Zhou <David1.Zhou@amd.com>
---
tests/amdgpu/basic_tests.c | 131 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 131 insertions(+)
diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c
index 02e863a..c7da54d 100644
--- a/tests/amdgpu/basic_tests.c
+++ b/tests/amdgpu/basic_tests.c
@@ -47,6 +47,7 @@ static void amdgpu_command_submission_sdma(void);
static void amdgpu_command_submission_multi_fence(void);
static void amdgpu_userptr_test(void);
static void amdgpu_semaphore_test(void);
+static void amdgpu_semaphore_across_process_test(void);
static void amdgpu_svm_test(void);
static void amdgpu_multi_svm_test(void);
static void amdgpu_va_range_test(void);
@@ -60,6 +61,7 @@ CU_TestInfo basic_tests[] = {
{ "Command submission Test (SDMA)", amdgpu_command_submission_sdma },
{ "Command submission Test (Multi-fence)", amdgpu_command_submission_multi_fence },
{ "SW semaphore Test", amdgpu_semaphore_test },
+ { "SW semaphore across process Test", amdgpu_semaphore_across_process_test },
{ "VA range Test", amdgpu_va_range_test},
{ "SVM Test", amdgpu_svm_test },
{ "SVM Test (multi-GPUs)", amdgpu_multi_svm_test },
@@ -515,6 +517,135 @@ static void amdgpu_command_submission_gfx(void)
amdgpu_command_submission_gfx_shared_ib();
}
+static void amdgpu_semaphore_across_process_test(void)
+{
+ struct amdgpu_context *context_handle;
+ amdgpu_semaphore_handle sem;
+ amdgpu_bo_handle ib_result_handle[2];
+ void *ib_result_cpu[2];
+ uint64_t ib_result_mc_address[2];
+ struct amdgpu_cs_request ibs_request[2] = {0};
+ struct amdgpu_cs_ib_info ib_info[2] = {0};
+ struct amdgpu_cs_fence fence_status = {0};
+ uint32_t *ptr;
+ uint32_t expired;
+ uint32_t shared_handle;
+ amdgpu_bo_list_handle bo_list[2];
+ amdgpu_va_handle va_handle[2];
+ int r, i, pid;
+
+ r = amdgpu_cs_create_semaphore_object(device_handle, &sem);
+ CU_ASSERT_EQUAL(r, 0);
+ r = amdgpu_cs_ctx_create(device_handle, &context_handle);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_bo_alloc_and_map(device_handle, 4096, 4096,
+ AMDGPU_GEM_DOMAIN_GTT, 0,
+ &ib_result_handle[0], &ib_result_cpu[0],
+ &ib_result_mc_address[0], &va_handle[0]);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_get_bo_list(device_handle, ib_result_handle[0],
+ NULL, &bo_list[0]);
+ CU_ASSERT_EQUAL(r, 0);
+
+ ptr = ib_result_cpu[0];
+ ptr[0] = SDMA_NOP;
+ ib_info[0].ib_mc_address = ib_result_mc_address[0];
+ ib_info[0].size = 1;
+
+ ibs_request[0].ip_type = AMDGPU_HW_IP_DMA;
+ ibs_request[0].number_of_ibs = 1;
+ ibs_request[0].ibs = &ib_info[0];
+ ibs_request[0].resources = bo_list[0];
+ ibs_request[0].fence_info.handle = NULL;
+ r = amdgpu_cs_submit(context_handle, 0,&ibs_request[0], 1);
+ CU_ASSERT_EQUAL(r, 0);
+ r = amdgpu_cs_signal_semaphore(context_handle, AMDGPU_HW_IP_DMA, 0, 0, sem);
+ CU_ASSERT_EQUAL(r, 0);
+ r = amdgpu_cs_export_semaphore(sem, &shared_handle);
+ CU_ASSERT_EQUAL(r, 0);
+
+ pid = fork();
+ /* child process */
+ if (pid == 0) {
+ amdgpu_device_handle child_device_handle;
+ uint32_t child_major_version;
+ uint32_t child_minor_version;
+ amdgpu_semaphore_handle child_sem;
+ amdgpu_context_handle context_handle1;
+
+ r = amdgpu_device_initialize(drm_amdgpu[0], &child_major_version,
+ &child_minor_version, &child_device_handle);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_bo_alloc_and_map(child_device_handle, 4096, 4096,
+ AMDGPU_GEM_DOMAIN_GTT, 0,
+ &ib_result_handle[1], &ib_result_cpu[1],
+ &ib_result_mc_address[1], &va_handle[1]);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_get_bo_list(child_device_handle, ib_result_handle[1],
+ NULL, &bo_list[1]);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_cs_import_semaphore(&child_sem, child_device_handle, shared_handle);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_cs_ctx_create(child_device_handle, &context_handle1);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_cs_wait_semaphore(context_handle1, AMDGPU_HW_IP_GFX, 0, 0, child_sem);
+ CU_ASSERT_EQUAL(r, 0);
+ ptr = ib_result_cpu[1];
+ ptr[0] = GFX_COMPUTE_NOP;
+ ib_info[1].ib_mc_address = ib_result_mc_address[1];
+ ib_info[1].size = 1;
+
+ ibs_request[1].ip_type = AMDGPU_HW_IP_GFX;
+ ibs_request[1].number_of_ibs = 1;
+ ibs_request[1].ibs = &ib_info[1];
+ ibs_request[1].resources = bo_list[1];
+ ibs_request[1].fence_info.handle = NULL;
+
+ r = amdgpu_cs_submit(context_handle1, 0,&ibs_request[1], 1);
+ CU_ASSERT_EQUAL(r, 0);
+
+ fence_status.context = context_handle1;
+ fence_status.ip_type = AMDGPU_HW_IP_GFX;
+ fence_status.fence = ibs_request[1].seq_no;
+ r = amdgpu_cs_query_fence_status(&fence_status,
+ 500000000, 0, &expired);
+ CU_ASSERT_EQUAL(r, 0);
+ CU_ASSERT_EQUAL(expired, true);
+
+ r = amdgpu_bo_unmap_and_free(ib_result_handle[1], va_handle[1],
+ ib_result_mc_address[1], 4096);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_bo_list_destroy(bo_list[1]);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_cs_ctx_free(context_handle1);
+ CU_ASSERT_EQUAL(r, 0);
+
+ amdgpu_device_deinitialize(child_device_handle);
+ } else {
+ r = amdgpu_bo_unmap_and_free(ib_result_handle[0], va_handle[0],
+ ib_result_mc_address[0], 4096);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_bo_list_destroy(bo_list[0]);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_cs_ctx_free(context_handle);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_cs_destroy_semaphore(sem);
+ CU_ASSERT_EQUAL(r, 0);
+ }
+}
+
static void amdgpu_semaphore_test(void)
{
amdgpu_context_handle context_handle[2];
--
1.9.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
prev parent reply other threads:[~2016-08-18 7:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-18 7:55 [PATCH 0/4] share semaphore across process Chunming Zhou
[not found] ` <1471506959-905-1-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2016-08-18 7:55 ` [PATCH 1/4] amdgpu: use drm_amdgpu_fence instead of amdgpu_cs_fence in semaphore structure Chunming Zhou
2016-08-18 7:55 ` [PATCH 2/4] amdgpu: add export/import semaphore apis Chunming Zhou
[not found] ` <1471506959-905-3-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2016-08-21 6:23 ` Edward O'Callaghan
[not found] ` <cf458d97-d40a-d363-b5c4-2ae45dde9179-dczkZgxz+BNUPWh3PAxdjQ@public.gmane.org>
2016-08-22 2:42 ` zhoucm1
[not found] ` <57BA6689.2010700-5C7GfCeVMHo@public.gmane.org>
2016-08-22 12:41 ` Edward O'Callaghan
[not found] ` <414bf811-0e72-6f79-350f-8995a2b5167c-dczkZgxz+BNUPWh3PAxdjQ@public.gmane.org>
2016-08-22 12:44 ` Edward O'Callaghan
2016-08-18 7:55 ` [PATCH 3/4] amdgpu: add mutex for across process reason Chunming Zhou
2016-08-18 7:55 ` Chunming Zhou [this message]
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=1471506959-905-5-git-send-email-David1.Zhou@amd.com \
--to=david1.zhou-5c7gfcevmho@public.gmane.org \
--cc=David.Mao-5C7GfCeVMHo@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.