dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] dma-buf/fence: make timeout handling in fence_default_wait consistent (v2)
@ 2016-11-07 21:16 Alex Deucher
       [not found] ` <1478553376-18575-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Alex Deucher @ 2016-11-07 21:16 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Alex Deucher, sumit.semwal-QSEj5FYQhm4dnm+yROfE0A

Kernel functions taking a timeout usually return 1 on success even
when they get a zero timeout.

v2: agd: rebase on drm-next

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signen-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---

These are the same patches Christian sent out previously, just
rebased on the fence naming changes in drm-next.

drivers/dma-buf/dma-fence.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
index 0c3141e7..6c3f6b4 100644
--- a/drivers/dma-buf/dma-fence.c
+++ b/drivers/dma-buf/dma-fence.c
@@ -339,18 +339,20 @@ dma_fence_default_wait_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
  * @timeout:	[in]	timeout value in jiffies, or MAX_SCHEDULE_TIMEOUT
  *
  * Returns -ERESTARTSYS if interrupted, 0 if the wait timed out, or the
- * remaining timeout in jiffies on success.
+ * remaining timeout in jiffies on success. If timeout is zero the value one is
+ * returned if the fence is already signaled for consistency with other
+ * functions taking a jiffies timeout.
  */
 signed long
 dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout)
 {
 	struct default_wait_cb cb;
 	unsigned long flags;
-	signed long ret = timeout;
+	signed long ret = timeout ? timeout : 1;
 	bool was_set;
 
 	if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
-		return timeout;
+		return ret;
 
 	spin_lock_irqsave(fence->lock, flags);
 
-- 
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] 6+ messages in thread

* [PATCH 2/4] dma-buf/fence: revert "don't wait when specified timeout is zero" (v2)
       [not found] ` <1478553376-18575-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
@ 2016-11-07 21:16   ` Alex Deucher
  0 siblings, 0 replies; 6+ messages in thread
From: Alex Deucher @ 2016-11-07 21:16 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Alex Deucher, sumit.semwal-QSEj5FYQhm4dnm+yROfE0A,
	Christian König

This reverts commit 847b19a39e4c9b5e74c40f0842c48b41664cb43c.

When we don't call the wait function software signaling might never be
activated. This can cause infinite polling loops with unreliable interrupt
driven hardware.

v2: rebase on drm-next

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/dma-buf/dma-fence.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
index 6c3f6b4..dd00990 100644
--- a/drivers/dma-buf/dma-fence.c
+++ b/drivers/dma-buf/dma-fence.c
@@ -161,9 +161,6 @@ dma_fence_wait_timeout(struct dma_fence *fence, bool intr, signed long timeout)
 	if (WARN_ON(timeout < 0))
 		return -EINVAL;
 
-	if (timeout == 0)
-		return dma_fence_is_signaled(fence);
-
 	trace_dma_fence_wait_start(fence);
 	ret = fence->ops->wait(fence, intr, timeout);
 	trace_dma_fence_wait_end(fence);
-- 
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] 6+ messages in thread

* [PATCH 3/4] drm/ttm: fix ttm_bo_wait
  2016-11-07 21:16 [PATCH 1/4] dma-buf/fence: make timeout handling in fence_default_wait consistent (v2) Alex Deucher
       [not found] ` <1478553376-18575-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
@ 2016-11-07 21:16 ` Alex Deucher
  2016-11-07 21:16 ` [PATCH 4/4] reservation: revert "wait only with non-zero timeout specified (v3)" v2 Alex Deucher
  2016-11-08 19:35 ` [PATCH 1/4] dma-buf/fence: make timeout handling in fence_default_wait consistent (v2) Sumit Semwal
  3 siblings, 0 replies; 6+ messages in thread
From: Alex Deucher @ 2016-11-07 21:16 UTC (permalink / raw)
  To: amd-gfx, dri-devel; +Cc: Alex Deucher, Christian König

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

reservation_object_wait_timeout_rcu() should enable signaling even with a zero
timeout, but ttm_bo_wait() can also be called from atomic context and then it
is not a good idea to do this.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index f6ff579..d506361 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1611,7 +1611,14 @@ EXPORT_SYMBOL(ttm_bo_unmap_virtual);
 int ttm_bo_wait(struct ttm_buffer_object *bo,
 		bool interruptible, bool no_wait)
 {
-	long timeout = no_wait ? 0 : 15 * HZ;
+	long timeout = 15 * HZ;
+
+	if (no_wait) {
+		if (reservation_object_test_signaled_rcu(bo->resv, true))
+			return 0;
+		else
+			return -EBUSY;
+	}
 
 	timeout = reservation_object_wait_timeout_rcu(bo->resv, true,
 						      interruptible, timeout);
-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 4/4] reservation: revert "wait only with non-zero timeout specified (v3)" v2
  2016-11-07 21:16 [PATCH 1/4] dma-buf/fence: make timeout handling in fence_default_wait consistent (v2) Alex Deucher
       [not found] ` <1478553376-18575-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2016-11-07 21:16 ` [PATCH 3/4] drm/ttm: fix ttm_bo_wait Alex Deucher
@ 2016-11-07 21:16 ` Alex Deucher
  2016-11-08  0:50   ` Gustavo Padovan
  2016-11-08 19:35 ` [PATCH 1/4] dma-buf/fence: make timeout handling in fence_default_wait consistent (v2) Sumit Semwal
  3 siblings, 1 reply; 6+ messages in thread
From: Alex Deucher @ 2016-11-07 21:16 UTC (permalink / raw)
  To: amd-gfx, dri-devel; +Cc: Alex Deucher, Christian König

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

This reverts commit fb8b7d2b9d80e1e71f379e57355936bd2b024be9.

Otherwise signaling might never be activated on the fences. This can
result in infinite waiting with hardware which has unreliable interrupts.

v2: still return one when the timeout is zero and we don't have any fences.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com> (v1)
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/dma-buf/reservation.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c
index 7ed56f3..393817e 100644
--- a/drivers/dma-buf/reservation.c
+++ b/drivers/dma-buf/reservation.c
@@ -370,10 +370,7 @@ long reservation_object_wait_timeout_rcu(struct reservation_object *obj,
 {
 	struct dma_fence *fence;
 	unsigned seq, shared_count, i = 0;
-	long ret = timeout;
-
-	if (!timeout)
-		return reservation_object_test_signaled_rcu(obj, wait_all);
+	long ret = timeout ? timeout : 1;
 
 retry:
 	fence = NULL;
-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 4/4] reservation: revert "wait only with non-zero timeout specified (v3)" v2
  2016-11-07 21:16 ` [PATCH 4/4] reservation: revert "wait only with non-zero timeout specified (v3)" v2 Alex Deucher
@ 2016-11-08  0:50   ` Gustavo Padovan
  0 siblings, 0 replies; 6+ messages in thread
From: Gustavo Padovan @ 2016-11-08  0:50 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Alex Deucher, dri-devel, amd-gfx, Christian König

2016-11-07 Alex Deucher <alexdeucher@gmail.com>:

> From: Christian König <christian.koenig@amd.com>
> 
> This reverts commit fb8b7d2b9d80e1e71f379e57355936bd2b024be9.
> 
> Otherwise signaling might never be activated on the fences. This can
> result in infinite waiting with hardware which has unreliable interrupts.
> 
> v2: still return one when the timeout is zero and we don't have any fences.
> 
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> Reviewed-by: Chunming Zhou <david1.zhou@amd.com> (v1)
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>  drivers/dma-buf/reservation.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)

You left all my r-b out. For the whole series:

Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk> 

Gustavo
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 1/4] dma-buf/fence: make timeout handling in fence_default_wait consistent (v2)
  2016-11-07 21:16 [PATCH 1/4] dma-buf/fence: make timeout handling in fence_default_wait consistent (v2) Alex Deucher
                   ` (2 preceding siblings ...)
  2016-11-07 21:16 ` [PATCH 4/4] reservation: revert "wait only with non-zero timeout specified (v3)" v2 Alex Deucher
@ 2016-11-08 19:35 ` Sumit Semwal
  3 siblings, 0 replies; 6+ messages in thread
From: Sumit Semwal @ 2016-11-08 19:35 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Alex Deucher, DRI mailing list, amd-gfx list

Hi Alex, Christian,

On 8 November 2016 at 02:46, Alex Deucher <alexdeucher@gmail.com> wrote:
> Kernel functions taking a timeout usually return 1 on success even
> when they get a zero timeout.
>
> v2: agd: rebase on drm-next
>
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> Signen-off-by: Christian König <christian.koenig@amd.com>
> Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>
> These are the same patches Christian sent out previously, just
> rebased on the fence naming changes in drm-next.
>
Series applied to drm-misc; Thanks!

Best,
Sumit.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2016-11-08 19:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-07 21:16 [PATCH 1/4] dma-buf/fence: make timeout handling in fence_default_wait consistent (v2) Alex Deucher
     [not found] ` <1478553376-18575-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2016-11-07 21:16   ` [PATCH 2/4] dma-buf/fence: revert "don't wait when specified timeout is zero" (v2) Alex Deucher
2016-11-07 21:16 ` [PATCH 3/4] drm/ttm: fix ttm_bo_wait Alex Deucher
2016-11-07 21:16 ` [PATCH 4/4] reservation: revert "wait only with non-zero timeout specified (v3)" v2 Alex Deucher
2016-11-08  0:50   ` Gustavo Padovan
2016-11-08 19:35 ` [PATCH 1/4] dma-buf/fence: make timeout handling in fence_default_wait consistent (v2) Sumit Semwal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).