diff mbox

[09/10] amdgpu: cs_wait_fences now can return the first signaled fence index

Message ID 1452633836-26855-10-git-send-email-maraeo@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Marek Olšák Jan. 12, 2016, 9:23 p.m. UTC
From: "monk.liu" <Monk.Liu@amd.com>

Signed-off-by: monk.liu <Monk.Liu@amd.com>
---
 amdgpu/amdgpu.h            |  3 ++-
 amdgpu/amdgpu_cs.c         | 12 +++++++++---
 include/drm/amdgpu_drm.h   |  3 ++-
 tests/amdgpu/basic_tests.c |  2 +-
 4 files changed, 14 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h
index 8822a0c..d4be7fc 100644
--- a/amdgpu/amdgpu.h
+++ b/amdgpu/amdgpu.h
@@ -916,6 +916,7 @@  int amdgpu_cs_query_fence_status(struct amdgpu_cs_fence *fence,
  *                                otherwise, wait at least one fence
  * \param   timeout_ns  - \c [in] The timeout to wait, in nanoseconds
  * \param   status      - \c [out] '1' for signaled, '0' for timeout
+ * \param   first       - \c [out] the index of the first signaled fence from @fences
  *
  * \return  0 on success
  *          <0 - Negative POSIX Error code
@@ -927,7 +928,7 @@  int amdgpu_cs_wait_fences(struct amdgpu_cs_fence *fences,
 			  uint32_t fence_count,
 			  bool wait_all,
 			  uint64_t timeout_ns,
-			  uint32_t *status);
+			  uint32_t *status, uint32_t *first);
 
 /*
  * Query / Info API
diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c
index d033f8e..5c7a3a3 100644
--- a/amdgpu/amdgpu_cs.c
+++ b/amdgpu/amdgpu_cs.c
@@ -439,7 +439,8 @@  static int amdgpu_ioctl_wait_fences(struct amdgpu_cs_fence *fences,
 				    uint32_t fence_count,
 				    bool wait_all,
 				    uint64_t timeout_ns,
-				    uint32_t *status)
+				    uint32_t *status,
+				    uint32_t *first)
 {
 	struct drm_amdgpu_fence *drm_fences;
 	amdgpu_device_handle dev = fences[0].context->dev;
@@ -467,6 +468,10 @@  static int amdgpu_ioctl_wait_fences(struct amdgpu_cs_fence *fences,
 		return -errno;
 
 	*status = args.out.status;
+
+	if (first)
+		*first = args.out.first_signaled;
+
 	return 0;
 }
 
@@ -474,7 +479,8 @@  int amdgpu_cs_wait_fences(struct amdgpu_cs_fence *fences,
 			  uint32_t fence_count,
 			  bool wait_all,
 			  uint64_t timeout_ns,
-			  uint32_t *status)
+			  uint32_t *status,
+			  uint32_t *first)
 {
 	uint32_t ioctl_status = 0;
 	uint32_t i;
@@ -499,7 +505,7 @@  int amdgpu_cs_wait_fences(struct amdgpu_cs_fence *fences,
 	*status = 0;
 
 	r = amdgpu_ioctl_wait_fences(fences, fence_count, wait_all, timeout_ns,
-					&ioctl_status);
+					&ioctl_status, first);
 
 	if (!r)
 		*status = ioctl_status;
diff --git a/include/drm/amdgpu_drm.h b/include/drm/amdgpu_drm.h
index 2cbea72..194e1f9 100644
--- a/include/drm/amdgpu_drm.h
+++ b/include/drm/amdgpu_drm.h
@@ -316,7 +316,8 @@  struct drm_amdgpu_wait_fences_in {
 };
 
 struct drm_amdgpu_wait_fences_out {
-	uint64_t status;
+	uint32_t status;
+	uint32_t first_signaled;
 };
 
 union drm_amdgpu_wait_fences {
diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c
index 56db935..47cd1db 100644
--- a/tests/amdgpu/basic_tests.c
+++ b/tests/amdgpu/basic_tests.c
@@ -974,7 +974,7 @@  static void amdgpu_command_submission_multi_fence_wait_all(bool wait_all)
 
 	r = amdgpu_cs_wait_fences(fence_status, ib_cs_num, wait_all,
 				AMDGPU_TIMEOUT_INFINITE,
-				&expired);
+				&expired, NULL);
 	CU_ASSERT_EQUAL(r, 0);
 
 	r = amdgpu_bo_unmap_and_free(ib_result_handle, va_handle,