From f91b56dc8c604ec1c6f092d69550266d20dc9764 Mon Sep 17 00:00:00 2001 From: Jammy Zhou Date: Thu, 9 Jul 2015 13:51:13 +0800 Subject: [PATCH] amdgpu: improve the amdgpu_cs_query_fence_status interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit make amdgpu_cs_query_fence reusable to support multi-fence query Signed-off-by: Jammy Zhou Reviewed-by: Christian König --- amdgpu/amdgpu.h | 11 ++++------- amdgpu/amdgpu_cs.c | 8 +++++--- tests/amdgpu/basic_tests.c | 20 ++++++++++++-------- tests/amdgpu/cs_tests.c | 5 +++-- tests/amdgpu/vce_tests.c | 5 +++-- 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h index a38e488e..027b549b 100644 --- a/amdgpu/amdgpu.h +++ b/amdgpu/amdgpu.h @@ -369,9 +369,6 @@ struct amdgpu_cs_query_fence { /** In which context IB was sent to execution */ amdgpu_context_handle context; - /** Timeout in nanoseconds. */ - uint64_t timeout_ns; - /** To which HW IP type the fence belongs */ unsigned ip_type; @@ -381,9 +378,6 @@ struct amdgpu_cs_query_fence { /** Ring index of the HW IP */ uint32_t ring; - /** Flags */ - uint64_t flags; - /** Specify fence for which we need to check submission status.*/ uint64_t fence; }; @@ -908,8 +902,9 @@ int amdgpu_cs_submit(amdgpu_context_handle context, /** * Query status of Command Buffer Submission * - * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() * \param fence - \c [in] Structure describing fence to query + * \param timeout_ns - \c [in] Timeout value to wait + * \param flags - \c [in] Flags for the query * \param expired - \c [out] If fence expired or not.\n * 0 – if fence is not expired\n * !0 - otherwise @@ -925,6 +920,8 @@ int amdgpu_cs_submit(amdgpu_context_handle context, * \sa amdgpu_cs_submit() */ int amdgpu_cs_query_fence_status(struct amdgpu_cs_query_fence *fence, + uint64_t timeout_ns, + uint64_t flags, uint32_t *expired); /* diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c index 15645274..03b17819 100644 --- a/amdgpu/amdgpu_cs.c +++ b/amdgpu/amdgpu_cs.c @@ -380,6 +380,8 @@ static int amdgpu_ioctl_wait_cs(amdgpu_context_handle context, } int amdgpu_cs_query_fence_status(struct amdgpu_cs_query_fence *fence, + uint64_t timeout_ns, + uint64_t flags, uint32_t *expired) { amdgpu_context_handle context; @@ -430,7 +432,7 @@ int amdgpu_cs_query_fence_status(struct amdgpu_cs_query_fence *fence, } /* Checking the user fence is enough. */ - if (fence->timeout_ns == 0) { + if (timeout_ns == 0) { pthread_mutex_unlock(&context->sequence_mutex); return 0; } @@ -439,8 +441,8 @@ int amdgpu_cs_query_fence_status(struct amdgpu_cs_query_fence *fence, pthread_mutex_unlock(&context->sequence_mutex); r = amdgpu_ioctl_wait_cs(context, ip_type, ip_instance, ring, - fence->fence, fence->timeout_ns, - fence->flags, &busy); + fence->fence, timeout_ns, + flags, &busy); if (!r && !busy) { *expired = true; pthread_mutex_lock(&context->sequence_mutex); diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c index 93743998..f369615e 100644 --- a/tests/amdgpu/basic_tests.c +++ b/tests/amdgpu/basic_tests.c @@ -215,10 +215,11 @@ static void amdgpu_command_submission_gfx_separate_ibs(void) CU_ASSERT_EQUAL(r, 0); fence_status.context = context_handle; - fence_status.timeout_ns = AMDGPU_TIMEOUT_INFINITE; fence_status.ip_type = AMDGPU_HW_IP_GFX; - r = amdgpu_cs_query_fence_status(&fence_status, &expired); + r = amdgpu_cs_query_fence_status(&fence_status, + AMDGPU_TIMEOUT_INFINITE, + 0, &expired); CU_ASSERT_EQUAL(r, 0); r = amdgpu_bo_free(ib_result_handle); @@ -289,10 +290,11 @@ static void amdgpu_command_submission_gfx_shared_ib(void) CU_ASSERT_EQUAL(r, 0); fence_status.context = context_handle; - fence_status.timeout_ns = AMDGPU_TIMEOUT_INFINITE; fence_status.ip_type = AMDGPU_HW_IP_GFX; - r = amdgpu_cs_query_fence_status(&fence_status, &expired); + r = amdgpu_cs_query_fence_status(&fence_status, + AMDGPU_TIMEOUT_INFINITE, + 0, &expired); CU_ASSERT_EQUAL(r, 0); r = amdgpu_bo_free(ib_result_handle); @@ -362,11 +364,12 @@ static void amdgpu_command_submission_compute(void) CU_ASSERT_EQUAL(r, 0); fence_status.context = context_handle; - fence_status.timeout_ns = AMDGPU_TIMEOUT_INFINITE; fence_status.ip_type = AMDGPU_HW_IP_COMPUTE; fence_status.ring = instance; - r = amdgpu_cs_query_fence_status(&fence_status, &expired); + r = amdgpu_cs_query_fence_status(&fence_status, + AMDGPU_TIMEOUT_INFINITE, + 0, &expired); CU_ASSERT_EQUAL(r, 0); r = amdgpu_bo_list_destroy(bo_list); @@ -446,10 +449,11 @@ static void amdgpu_sdma_test_exec_cs(amdgpu_context_handle context_handle, fence_status.ip_type = AMDGPU_HW_IP_DMA; fence_status.ring = ibs_request->ring; fence_status.context = context_handle; - fence_status.timeout_ns = AMDGPU_TIMEOUT_INFINITE; /* wait for IB accomplished */ - r = amdgpu_cs_query_fence_status(&fence_status, &expired); + r = amdgpu_cs_query_fence_status(&fence_status, + AMDGPU_TIMEOUT_INFINITE, + 0, &expired); CU_ASSERT_EQUAL(r, 0); CU_ASSERT_EQUAL(expired, true); diff --git a/tests/amdgpu/cs_tests.c b/tests/amdgpu/cs_tests.c index 63cdbb5b..c303cc30 100644 --- a/tests/amdgpu/cs_tests.c +++ b/tests/amdgpu/cs_tests.c @@ -140,10 +140,11 @@ static int submit(unsigned ndw, unsigned ip) return r; fence_status.context = context_handle; - fence_status.timeout_ns = AMDGPU_TIMEOUT_INFINITE; fence_status.ip_type = ip; - r = amdgpu_cs_query_fence_status(&fence_status, &expired); + r = amdgpu_cs_query_fence_status(&fence_status, + AMDGPU_TIMEOUT_INFINITE, + 0, &expired); if (r) return r; diff --git a/tests/amdgpu/vce_tests.c b/tests/amdgpu/vce_tests.c index 70e378cd..09e8607c 100644 --- a/tests/amdgpu/vce_tests.c +++ b/tests/amdgpu/vce_tests.c @@ -165,10 +165,11 @@ static int submit(unsigned ndw, unsigned ip) resources[num_resources-1] = ib_handle; fence_status.context = context_handle; - fence_status.timeout_ns = AMDGPU_TIMEOUT_INFINITE; fence_status.ip_type = ip; - r = amdgpu_cs_query_fence_status(&fence_status, &expired); + r = amdgpu_cs_query_fence_status(&fence_status, + AMDGPU_TIMEOUT_INFINITE, + 0, &expired); if (r) return r;