All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] dma-buf: return index of the first signaled fence
@ 2016-09-12 18:59 Alex Deucher
       [not found] ` <1473706747-31065-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Deucher @ 2016-09-12 18:59 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	sumit.semwal-QSEj5FYQhm4dnm+yROfE0A
  Cc: Alex Deucher, monk.liu

From: "monk.liu" <monk.liu@amd.com>

Return the index of the first signaled fence.  This information
is useful in some APIs like Vulkan.

Signed-off-by: monk.liu <monk.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/dma-buf/fence.c | 19 ++++++++++++++-----
 include/linux/fence.h   |  2 +-
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/dma-buf/fence.c b/drivers/dma-buf/fence.c
index 4d51f9e..90b7d27 100644
--- a/drivers/dma-buf/fence.c
+++ b/drivers/dma-buf/fence.c
@@ -398,14 +398,17 @@ out:
 EXPORT_SYMBOL(fence_default_wait);
 
 static bool
-fence_test_signaled_any(struct fence **fences, uint32_t count)
+fence_test_signaled_any(struct fence **fences, uint32_t count, uint32_t *idx)
 {
 	int i;
 
 	for (i = 0; i < count; ++i) {
 		struct fence *fence = fences[i];
-		if (test_bit(FENCE_FLAG_SIGNALED_BIT, &fence->flags))
+		if (test_bit(FENCE_FLAG_SIGNALED_BIT, &fence->flags)) {
+			if (idx)
+				*idx = i;
 			return true;
+		}
 	}
 	return false;
 }
@@ -417,6 +420,7 @@ fence_test_signaled_any(struct fence **fences, uint32_t count)
  * @count:	[in]	number of fences to wait on
  * @intr:	[in]	if true, do an interruptible wait
  * @timeout:	[in]	timeout value in jiffies, or MAX_SCHEDULE_TIMEOUT
+ * @idx:	[out]	the first signaled fence index, meaninful only on Returns positive
  *
  * Returns -EINVAL on custom fence wait implementation, -ERESTARTSYS if
  * interrupted, 0 if the wait timed out, or the remaining timeout in jiffies
@@ -428,7 +432,7 @@ fence_test_signaled_any(struct fence **fences, uint32_t count)
  */
 signed long
 fence_wait_any_timeout(struct fence **fences, uint32_t count,
-		       bool intr, signed long timeout)
+		       bool intr, signed long timeout, uint32_t *idx)
 {
 	struct default_wait_cb *cb;
 	signed long ret = timeout;
@@ -439,8 +443,11 @@ fence_wait_any_timeout(struct fence **fences, uint32_t count,
 
 	if (timeout == 0) {
 		for (i = 0; i < count; ++i)
-			if (fence_is_signaled(fences[i]))
+			if (fence_is_signaled(fences[i])) {
+				if (idx)
+					*idx = i;
 				return 1;
+			}
 
 		return 0;
 	}
@@ -463,6 +470,8 @@ fence_wait_any_timeout(struct fence **fences, uint32_t count,
 		if (fence_add_callback(fence, &cb[i].base,
 				       fence_default_wait_cb)) {
 			/* This fence is already signaled */
+			if (idx)
+				*idx = i;
 			goto fence_rm_cb;
 		}
 	}
@@ -473,7 +482,7 @@ fence_wait_any_timeout(struct fence **fences, uint32_t count,
 		else
 			set_current_state(TASK_UNINTERRUPTIBLE);
 
-		if (fence_test_signaled_any(fences, count))
+		if (fence_test_signaled_any(fences, count, idx))
 			break;
 
 		ret = schedule_timeout(ret);
diff --git a/include/linux/fence.h b/include/linux/fence.h
index 8cc719a..2d21113 100644
--- a/include/linux/fence.h
+++ b/include/linux/fence.h
@@ -325,7 +325,7 @@ static inline struct fence *fence_later(struct fence *f1, struct fence *f2)
 
 signed long fence_wait_timeout(struct fence *, bool intr, signed long timeout);
 signed long fence_wait_any_timeout(struct fence **fences, uint32_t count,
-				   bool intr, signed long timeout);
+				   bool intr, signed long timeout, uint32_t *idx);
 
 /**
  * fence_wait - sleep until the fence gets signaled
-- 
2.5.5

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] drm/amdgpu: return first signaled fence index in status parameter
       [not found] ` <1473706747-31065-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
@ 2016-09-12 18:59   ` Alex Deucher
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2016-09-12 18:59 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	sumit.semwal-QSEj5FYQhm4dnm+yROfE0A
  Cc: Alex Deucher, monk.liu

From: "monk.liu" <monk.liu@amd.com>

Return the index of the first signaled fence in the fences ioctl.
This information is useful in some APIs like Vulkan.

Signed-off-by: monk.liu <monk.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 +++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c | 2 +-
 include/uapi/drm/amdgpu_drm.h          | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 384856c..8247b7a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -1191,6 +1191,7 @@ static int amdgpu_cs_wait_any_fence(struct amdgpu_device *adev,
 {
 	unsigned long timeout = amdgpu_gem_timeout(wait->in.timeout_ns);
 	uint32_t fence_count = wait->in.fence_count;
+	uint32_t first = ~0;
 	struct fence **array;
 	unsigned i;
 	long r;
@@ -1216,13 +1217,14 @@ static int amdgpu_cs_wait_any_fence(struct amdgpu_device *adev,
 		}
 	}
 
-	r = fence_wait_any_timeout(array, fence_count, true, timeout);
+	r = fence_wait_any_timeout(array, fence_count, true, timeout, &first);
 	if (r < 0)
 		goto err_free_fence_array;
 
 out:
 	memset(wait, 0, sizeof(*wait));
 	wait->out.status = (r > 0);
+	wait->out.first_signaled = first;
 	/* set return value 0 to indicate success */
 	r = 0;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c
index d8af37a..ed50d77 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c
@@ -361,7 +361,7 @@ int amdgpu_sa_bo_new(struct amdgpu_sa_manager *sa_manager,
 		if (count) {
 			spin_unlock(&sa_manager->wq.lock);
 			t = fence_wait_any_timeout(fences, count, false,
-						   MAX_SCHEDULE_TIMEOUT);
+						   MAX_SCHEDULE_TIMEOUT, NULL);
 			for (i = 0; i < count; ++i)
 				fence_put(fences[i]);
 
diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
index dd9c99c..3c549f3 100644
--- a/include/uapi/drm/amdgpu_drm.h
+++ b/include/uapi/drm/amdgpu_drm.h
@@ -324,7 +324,8 @@ struct drm_amdgpu_wait_fences_in {
 };
 
 struct drm_amdgpu_wait_fences_out {
-	__u64 status;
+	__u32 status;
+	__u32 first_signaled;
 };
 
 union drm_amdgpu_wait_fences {
-- 
2.5.5

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-12 18:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-12 18:59 [PATCH 1/2] dma-buf: return index of the first signaled fence Alex Deucher
     [not found] ` <1473706747-31065-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2016-09-12 18:59   ` [PATCH 2/2] drm/amdgpu: return first signaled fence index in status parameter Alex Deucher

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.