All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/28] drm/i915: Fix i915_request fence wait semantics
@ 2021-10-21 10:35 ` Maarten Lankhorst
  0 siblings, 0 replies; 114+ messages in thread
From: Maarten Lankhorst @ 2021-10-21 10:35 UTC (permalink / raw)
  To: intel-gfx; +Cc: dri-devel, Maarten Lankhorst

The i915_request fence wait behaves differently for timeout = 0
compared to expected dma-fence behavior.

i915 behavior:
- Unsignaled: -ETIME
- Signaled: 0 (= timeout)

Expected:
- Unsignaled: 0
- Signaled: 1

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_request.c | 57 ++++++++++++++++++++++++-----
 drivers/gpu/drm/i915/i915_request.h |  5 +++
 2 files changed, 52 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index 820a1f38b271..42cd17357771 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -96,9 +96,9 @@ static signed long i915_fence_wait(struct dma_fence *fence,
 				   bool interruptible,
 				   signed long timeout)
 {
-	return i915_request_wait(to_request(fence),
-				 interruptible | I915_WAIT_PRIORITY,
-				 timeout);
+	return i915_request_wait_timeout(to_request(fence),
+					 interruptible | I915_WAIT_PRIORITY,
+					 timeout);
 }
 
 struct kmem_cache *i915_request_slab_cache(void)
@@ -1857,23 +1857,27 @@ static void request_wait_wake(struct dma_fence *fence, struct dma_fence_cb *cb)
 }
 
 /**
- * i915_request_wait - wait until execution of request has finished
+ * i915_request_wait_timeout - wait until execution of request has finished
  * @rq: the request to wait upon
  * @flags: how to wait
  * @timeout: how long to wait in jiffies
  *
- * i915_request_wait() waits for the request to be completed, for a
+ * i915_request_wait_timeout() waits for the request to be completed, for a
  * maximum of @timeout jiffies (with MAX_SCHEDULE_TIMEOUT implying an
  * unbounded wait).
  *
  * Returns the remaining time (in jiffies) if the request completed, which may
- * be zero or -ETIME if the request is unfinished after the timeout expires.
+ * be zero if the request is unfinished after the timeout expires.
+ * If the timeout is 0, it will return 1 if the fence is signaled.
+ *
  * May return -EINTR is called with I915_WAIT_INTERRUPTIBLE and a signal is
  * pending before the request completes.
+ *
+ * NOTE: This function has the same wait semantics as dma-fence.
  */
-long i915_request_wait(struct i915_request *rq,
-		       unsigned int flags,
-		       long timeout)
+long i915_request_wait_timeout(struct i915_request *rq,
+			       unsigned int flags,
+			       long timeout)
 {
 	const int state = flags & I915_WAIT_INTERRUPTIBLE ?
 		TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE;
@@ -1883,7 +1887,7 @@ long i915_request_wait(struct i915_request *rq,
 	GEM_BUG_ON(timeout < 0);
 
 	if (dma_fence_is_signaled(&rq->fence))
-		return timeout;
+		return timeout ?: 1;
 
 	if (!timeout)
 		return -ETIME;
@@ -1992,6 +1996,39 @@ long i915_request_wait(struct i915_request *rq,
 	return timeout;
 }
 
+/**
+ * i915_request_wait - wait until execution of request has finished
+ * @rq: the request to wait upon
+ * @flags: how to wait
+ * @timeout: how long to wait in jiffies
+ *
+ * i915_request_wait() waits for the request to be completed, for a
+ * maximum of @timeout jiffies (with MAX_SCHEDULE_TIMEOUT implying an
+ * unbounded wait).
+ *
+ * Returns the remaining time (in jiffies) if the request completed, which may
+ * be zero or -ETIME if the request is unfinished after the timeout expires.
+ * May return -EINTR is called with I915_WAIT_INTERRUPTIBLE and a signal is
+ * pending before the request completes.
+ *
+ * NOTE: This function behaves differently from dma-fence wait semantics for
+ * timeout = 0. It returns 0 on success, and -ETIME if not signaled.
+ */
+long i915_request_wait(struct i915_request *rq,
+		       unsigned int flags,
+		       long timeout)
+{
+	long ret = i915_request_wait_timeout(rq, flags, timeout);
+
+	if (!ret)
+		return -ETIME;
+
+	if (ret > 0 && !timeout)
+		return 0;
+
+	return ret;
+}
+
 static int print_sched_attr(const struct i915_sched_attr *attr,
 			    char *buf, int x, int len)
 {
diff --git a/drivers/gpu/drm/i915/i915_request.h b/drivers/gpu/drm/i915/i915_request.h
index dc359242d1ae..3c6e8acd1457 100644
--- a/drivers/gpu/drm/i915/i915_request.h
+++ b/drivers/gpu/drm/i915/i915_request.h
@@ -414,6 +414,11 @@ void i915_request_unsubmit(struct i915_request *request);
 
 void i915_request_cancel(struct i915_request *rq, int error);
 
+long i915_request_wait_timeout(struct i915_request *rq,
+			       unsigned int flags,
+			       long timeout)
+	__attribute__((nonnull(1)));
+
 long i915_request_wait(struct i915_request *rq,
 		       unsigned int flags,
 		       long timeout)
-- 
2.33.0


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

end of thread, other threads:[~2021-11-29 13:44 UTC | newest]

Thread overview: 114+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21 10:35 [PATCH 01/28] drm/i915: Fix i915_request fence wait semantics Maarten Lankhorst
2021-10-21 10:35 ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 10:35 ` [PATCH 02/28] drm/i915: use new iterator in i915_gem_object_wait_reservation Maarten Lankhorst
2021-10-21 10:35   ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 10:38   ` Christian König
2021-10-21 10:38     ` [Intel-gfx] " Christian König
2021-10-21 11:06     ` Maarten Lankhorst
2021-10-21 11:06       ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 11:13       ` Tvrtko Ursulin
2021-10-28  8:41         ` Christian König
2021-10-28 15:30           ` Daniel Vetter
2021-11-01  9:41             ` Tvrtko Ursulin
2021-11-11 11:36               ` Christian König
2021-11-12 16:07                 ` Daniel Vetter
2021-11-12 16:07                   ` Daniel Vetter
2021-10-21 10:35 ` [PATCH 03/28] drm/i915: Remove dma_resv_prune Maarten Lankhorst
2021-10-21 10:35   ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 14:43   ` Matthew Auld
2021-10-21 14:43     ` [Intel-gfx] " Matthew Auld
2021-10-22  8:48     ` Maarten Lankhorst
2021-10-22  8:48       ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 10:35 ` [PATCH 04/28] drm/i915: Remove unused bits of i915_vma/active api Maarten Lankhorst
2021-10-21 10:35   ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 10:35 ` [PATCH 05/28] drm/i915: Slightly rework EXEC_OBJECT_CAPTURE handling, v2 Maarten Lankhorst
2021-10-21 10:35   ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 10:35 ` [PATCH 06/28] drm/i915: Remove gen6_ppgtt_unpin_all Maarten Lankhorst
2021-10-21 10:35   ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 10:35 ` [PATCH 07/28] drm/i915: Create a dummy object for gen6 ppgtt Maarten Lankhorst
2021-10-21 10:35   ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 15:42   ` Matthew Auld
2021-10-21 10:35 ` [PATCH 08/28] drm/i915: Create a full object for mock_ring, v2 Maarten Lankhorst
2021-10-21 10:35   ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 15:57   ` Matthew Auld
2021-10-21 15:57     ` [Intel-gfx] " Matthew Auld
2021-10-22 11:03     ` Maarten Lankhorst
2021-10-22 11:03       ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 10:35 ` [PATCH 09/28] drm/i915: vma is always backed by an object Maarten Lankhorst
2021-10-21 10:35   ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 16:09   ` Matthew Auld
2021-10-21 10:35 ` [Intel-gfx] [PATCH 10/28] drm/i915: Change shrink ordering to use locking around unbinding Maarten Lankhorst
2021-10-21 10:35   ` Maarten Lankhorst
2021-10-21 16:12   ` [Intel-gfx] " Matthew Auld
2021-10-22 11:04     ` Maarten Lankhorst
2021-10-21 10:35 ` [PATCH 11/28] drm/i915/pm: Move CONTEXT_VALID_BIT check Maarten Lankhorst
2021-10-21 10:35   ` [Intel-gfx] " Maarten Lankhorst
2021-11-02 16:13   ` Matthew Auld
2021-11-02 16:13     ` Matthew Auld
2021-10-21 10:35 ` [PATCH 12/28] drm/i915: Remove resv from i915_vma Maarten Lankhorst
2021-10-21 10:35   ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 10:35 ` [Intel-gfx] [PATCH 13/28] drm/i915: Remove pages_mutex and intel_gtt->vma_ops.set/clear_pages members Maarten Lankhorst
2021-10-21 10:35   ` Maarten Lankhorst
2021-10-21 17:30   ` [Intel-gfx] " Matthew Auld
2021-10-22 10:59     ` Matthew Auld
2021-11-29 12:40       ` Maarten Lankhorst
2021-10-21 10:35 ` [PATCH 14/28] drm/i915: Take object lock in i915_ggtt_pin if ww is not set Maarten Lankhorst
2021-10-21 10:35   ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 17:39   ` Matthew Auld
2021-11-29 12:46     ` Maarten Lankhorst
2021-10-21 10:35 ` [Intel-gfx] [PATCH 15/28] drm/i915: Add lock for unbinding to i915_gem_object_ggtt_pin_ww Maarten Lankhorst
2021-10-21 10:35   ` Maarten Lankhorst
2021-10-21 17:48   ` [Intel-gfx] " Matthew Auld
2021-11-29 13:25     ` Maarten Lankhorst
2021-10-21 10:35 ` [PATCH 16/28] drm/i915: Rework context handling in hugepages selftests Maarten Lankhorst
2021-10-21 10:35   ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 17:55   ` Matthew Auld
2021-10-22  6:51   ` kernel test robot
2021-10-22  6:51     ` kernel test robot
2021-10-22  7:21   ` kernel test robot
2021-10-22  7:21     ` kernel test robot
2021-11-03 11:33   ` kernel test robot
2021-11-03 11:33   ` [RFC PATCH] drm/i915: hugepage_ctx() can be static kernel test robot
2021-10-21 10:35 ` [PATCH 17/28] drm/i915: Ensure gem_contexts selftests work with unbind changes Maarten Lankhorst
2021-10-21 10:35   ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 10:35 ` [Intel-gfx] [PATCH 18/28] drm/i915: Take trylock during eviction, v2 Maarten Lankhorst
2021-10-21 10:35   ` Maarten Lankhorst
2021-10-21 17:59   ` [Intel-gfx] " Matthew Auld
2021-10-22  8:44     ` Maarten Lankhorst
2021-10-22  8:44       ` Maarten Lankhorst
2021-10-21 10:35 ` [PATCH 19/28] drm/i915: Pass trylock context to callers Maarten Lankhorst
2021-10-21 10:35   ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 18:03   ` Matthew Auld
2021-10-22  8:52     ` Maarten Lankhorst
2021-10-21 10:35 ` [PATCH 20/28] drm/i915: Ensure i915_vma tests do not get -ENOSPC with the locking changes Maarten Lankhorst
2021-10-21 10:35   ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 10:35 ` [PATCH 21/28] drm/i915: Drain the ttm delayed workqueue too Maarten Lankhorst
2021-10-21 10:35   ` [Intel-gfx] " Maarten Lankhorst
2021-10-25 15:11   ` Matthew Auld
2021-10-25 15:11     ` [Intel-gfx] " Matthew Auld
2021-10-21 10:35 ` [PATCH 22/28] drm/i915: Make i915_gem_evict_vm work correctly for already locked objects Maarten Lankhorst
2021-10-21 10:35   ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 10:36 ` [Intel-gfx] [PATCH 23/28] drm/i915: Call i915_gem_evict_vm in vm_fault_gtt to prevent new ENOSPC errors Maarten Lankhorst
2021-10-21 10:36   ` Maarten Lankhorst
2021-10-21 10:36 ` [PATCH 24/28] drm/i915: Add i915_vma_unbind_unlocked, and take obj lock for i915_vma_unbind Maarten Lankhorst
2021-10-21 10:36   ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 10:36 ` [PATCH 25/28] drm/i915: Require object lock when freeing pages during destruction Maarten Lankhorst
2021-10-21 10:36   ` [Intel-gfx] " Maarten Lankhorst
2021-10-22 11:10   ` Matthew Auld
2021-10-21 10:36 ` [PATCH 26/28] drm/i915: Remove assert_object_held_shared Maarten Lankhorst
2021-10-21 10:36   ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 10:36 ` [PATCH 27/28] drm/i915: Remove support for unlocked i915_vma unbind Maarten Lankhorst
2021-10-21 10:36   ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 10:36 ` [PATCH 28/28] drm/i915: Remove short-term pins from execbuf, v4 Maarten Lankhorst
2021-10-21 10:36   ` [Intel-gfx] " Maarten Lankhorst
2021-10-25 15:02   ` Matthew Auld
2021-10-25 15:02     ` [Intel-gfx] " Matthew Auld
2021-11-29 13:44     ` Maarten Lankhorst
2021-11-29 13:44       ` [Intel-gfx] " Maarten Lankhorst
2021-10-21 10:56 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/28] drm/i915: Fix i915_request fence wait semantics Patchwork
2021-10-21 10:57 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-10-21 11:01 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2021-10-21 11:27 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-10-21 12:57 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2021-10-22 11:24   ` Matthew Auld
2021-10-22 13:17     ` Maarten Lankhorst

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.