From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Intel-gfx@lists.freedesktop.org
Subject: [PATCH 3/5] drm/i915: Add timeline barrier support
Date: Wed, 30 Jan 2019 09:34:14 +0000 [thread overview]
Message-ID: <20190130093416.3513-4-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <20190130093416.3513-1-tvrtko.ursulin@linux.intel.com>
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Timeline barrier allows serialization between different timelines.
After calling i915_timeline_set_barrier with a request, all following
submissions on this timeline will be set up as depending on this request,
or barrier. Once the barrier has been completed it automatically gets
cleared and things continue as normal.
This facility will be used by the upcoming context SSEU code.
v2:
* Assert barrier has been retired on timeline_fini. (Chris Wilson)
* Fix mock_timeline.
v3:
* Improved comment language. (Chris Wilson)
v4:
* Maintain ordering with previous barriers set on the timeline.
v5:
* Rebase.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_request.c | 17 ++++++++++++++
drivers/gpu/drm/i915/i915_timeline.c | 21 ++++++++++++++++++
drivers/gpu/drm/i915/i915_timeline.h | 22 +++++++++++++++++++
.../gpu/drm/i915/selftests/mock_timeline.c | 1 +
4 files changed, 61 insertions(+)
diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index 9ed5baf157a3..4b1869295362 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -526,6 +526,19 @@ i915_request_alloc_slow(struct intel_context *ce)
return kmem_cache_alloc(ce->gem_context->i915->requests, GFP_KERNEL);
}
+static int add_barrier(struct i915_request *rq, struct i915_gem_active *active)
+{
+ struct i915_request *barrier =
+ i915_gem_active_raw(active, &rq->i915->drm.struct_mutex);
+
+ return barrier ? i915_request_await_dma_fence(rq, &barrier->fence) : 0;
+}
+
+static int add_timeline_barrier(struct i915_request *rq)
+{
+ return add_barrier(rq, &rq->timeline->barrier);
+}
+
/**
* i915_request_alloc - allocate a request structure
*
@@ -668,6 +681,10 @@ i915_request_alloc(struct intel_engine_cs *engine, struct i915_gem_context *ctx)
*/
rq->head = rq->ring->emit;
+ ret = add_timeline_barrier(rq);
+ if (ret)
+ goto err_unwind;
+
ret = engine->request_alloc(rq);
if (ret)
goto err_unwind;
diff --git a/drivers/gpu/drm/i915/i915_timeline.c b/drivers/gpu/drm/i915/i915_timeline.c
index 5ea3af393ffe..dcff3ae96683 100644
--- a/drivers/gpu/drm/i915/i915_timeline.c
+++ b/drivers/gpu/drm/i915/i915_timeline.c
@@ -163,6 +163,7 @@ int i915_timeline_init(struct drm_i915_private *i915,
spin_lock_init(&timeline->lock);
+ init_request_active(&timeline->barrier, NULL);
init_request_active(&timeline->last_request, NULL);
INIT_LIST_HEAD(&timeline->requests);
@@ -235,6 +236,7 @@ void i915_timeline_fini(struct i915_timeline *timeline)
{
GEM_BUG_ON(timeline->pin_count);
GEM_BUG_ON(!list_empty(&timeline->requests));
+ GEM_BUG_ON(i915_gem_active_isset(&timeline->barrier));
i915_syncmap_free(&timeline->sync);
hwsp_free(timeline);
@@ -309,6 +311,25 @@ void i915_timeline_unpin(struct i915_timeline *tl)
__i915_vma_unpin(tl->hwsp_ggtt);
}
+int i915_timeline_set_barrier(struct i915_timeline *tl, struct i915_request *rq)
+{
+ struct i915_request *old;
+ int err;
+
+ lockdep_assert_held(&rq->i915->drm.struct_mutex);
+
+ /* Must maintain ordering wrt existing barriers */
+ old = i915_gem_active_raw(&tl->barrier, &rq->i915->drm.struct_mutex);
+ if (old) {
+ err = i915_request_await_dma_fence(rq, &old->fence);
+ if (err)
+ return err;
+ }
+
+ i915_gem_active_set(&tl->barrier, rq);
+ return 0;
+}
+
void __i915_timeline_free(struct kref *kref)
{
struct i915_timeline *timeline =
diff --git a/drivers/gpu/drm/i915/i915_timeline.h b/drivers/gpu/drm/i915/i915_timeline.h
index 8caeb66d1cd5..d167e04073c5 100644
--- a/drivers/gpu/drm/i915/i915_timeline.h
+++ b/drivers/gpu/drm/i915/i915_timeline.h
@@ -74,6 +74,16 @@ struct i915_timeline {
*/
struct i915_syncmap *sync;
+ /**
+ * Barrier provides the ability to serialize ordering between different
+ * timelines.
+ *
+ * Users can call i915_timeline_set_barrier which will make all
+ * subsequent submissions to this timeline be executed only after the
+ * barrier has been completed.
+ */
+ struct i915_gem_active barrier;
+
struct list_head link;
const char *name;
struct drm_i915_private *i915;
@@ -155,4 +165,16 @@ void i915_timelines_init(struct drm_i915_private *i915);
void i915_timelines_park(struct drm_i915_private *i915);
void i915_timelines_fini(struct drm_i915_private *i915);
+/**
+ * i915_timeline_set_barrier - orders submission between different timelines
+ * @timeline: timeline to set the barrier on
+ * @rq: request after which new submissions can proceed
+ *
+ * Sets the passed in request as the serialization point for all subsequent
+ * submissions on @timeline. Subsequent requests will not be submitted to GPU
+ * until the barrier has been completed.
+ */
+int i915_timeline_set_barrier(struct i915_timeline *timeline,
+ struct i915_request *rq);
+
#endif
diff --git a/drivers/gpu/drm/i915/selftests/mock_timeline.c b/drivers/gpu/drm/i915/selftests/mock_timeline.c
index cf39ccd9fc05..e5659aaa856d 100644
--- a/drivers/gpu/drm/i915/selftests/mock_timeline.c
+++ b/drivers/gpu/drm/i915/selftests/mock_timeline.c
@@ -15,6 +15,7 @@ void mock_timeline_init(struct i915_timeline *timeline, u64 context)
spin_lock_init(&timeline->lock);
+ init_request_active(&timeline->barrier, NULL);
init_request_active(&timeline->last_request, NULL);
INIT_LIST_HEAD(&timeline->requests);
--
2.19.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-01-30 9:34 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-30 9:34 [PATCH 0/5] Per context dynamic (sub)slice power-gating Tvrtko Ursulin
2019-01-30 9:34 ` [PATCH 1/5] drm/i915: Record the sseu configuration per-context & engine Tvrtko Ursulin
2019-01-30 9:40 ` Chris Wilson
2019-01-30 9:56 ` Tvrtko Ursulin
2019-01-30 10:14 ` [PATCH v16 " Tvrtko Ursulin
2019-01-30 9:34 ` [PATCH 2/5] drm/i915/perf: lock powergating configuration to default when active Tvrtko Ursulin
2019-01-30 9:34 ` Tvrtko Ursulin [this message]
2019-01-30 9:34 ` [PATCH 4/5] drm/i915: Expose RPCS (SSEU) configuration to userspace (Gen11 only) Tvrtko Ursulin
2019-01-30 9:45 ` Chris Wilson
2019-01-30 9:59 ` Tvrtko Ursulin
2019-01-30 10:15 ` [PATCH v29 " Tvrtko Ursulin
2019-01-31 8:47 ` [PATCH v30 " Tvrtko Ursulin
2019-01-31 9:15 ` Chris Wilson
2019-01-31 9:34 ` Tvrtko Ursulin
2019-01-31 10:47 ` [PATCH v31 " Tvrtko Ursulin
2019-01-31 10:59 ` Chris Wilson
2019-01-31 11:46 ` Joonas Lahtinen
2019-01-30 9:34 ` [PATCH 5/5] drm/i915/selftests: Context SSEU reconfiguration tests Tvrtko Ursulin
2019-01-30 9:47 ` ✗ Fi.CI.CHECKPATCH: warning for Per context dynamic (sub)slice power-gating (rev21) Patchwork
2019-01-30 9:50 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-01-30 10:12 ` ✓ Fi.CI.BAT: success " Patchwork
2019-01-30 11:12 ` ✗ Fi.CI.CHECKPATCH: warning for Per context dynamic (sub)slice power-gating (rev23) Patchwork
2019-01-30 11:15 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-01-30 11:31 ` ✗ Fi.CI.IGT: failure for Per context dynamic (sub)slice power-gating (rev21) Patchwork
2019-01-30 11:45 ` ✓ Fi.CI.BAT: success for Per context dynamic (sub)slice power-gating (rev23) Patchwork
2019-01-30 13:12 ` ✗ Fi.CI.CHECKPATCH: warning for Per context dynamic (sub)slice power-gating (rev24) Patchwork
2019-01-30 13:15 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-01-30 13:34 ` ✓ Fi.CI.BAT: success " Patchwork
2019-01-30 13:52 ` ✗ Fi.CI.CHECKPATCH: warning for Per context dynamic (sub)slice power-gating (rev25) Patchwork
2019-01-30 13:55 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-01-30 14:14 ` ✗ Fi.CI.BAT: failure " Patchwork
2019-01-30 16:23 ` ✗ Fi.CI.CHECKPATCH: warning for Per context dynamic (sub)slice power-gating (rev26) Patchwork
2019-01-30 16:26 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-01-30 16:45 ` ✓ Fi.CI.BAT: success " Patchwork
2019-01-30 20:51 ` ✓ Fi.CI.IGT: " Patchwork
2019-01-31 7:25 ` Tvrtko Ursulin
2019-01-31 7:30 ` Chris Wilson
2019-01-31 8:26 ` ✗ Fi.CI.CHECKPATCH: warning for Per context dynamic (sub)slice power-gating (rev27) Patchwork
2019-01-31 8:29 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-01-31 8:48 ` ✓ Fi.CI.BAT: success " Patchwork
2019-01-31 9:49 ` ✗ Fi.CI.CHECKPATCH: warning for Per context dynamic (sub)slice power-gating (rev28) Patchwork
2019-01-31 9:51 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-01-31 10:14 ` ✓ Fi.CI.BAT: success " Patchwork
2019-01-31 11:11 ` ✗ Fi.CI.CHECKPATCH: warning for Per context dynamic (sub)slice power-gating (rev29) Patchwork
2019-01-31 11:14 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-01-31 11:32 ` ✓ Fi.CI.BAT: success " Patchwork
2019-01-31 21:49 ` ✓ Fi.CI.IGT: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2019-01-25 15:24 [PATCH 0/5] Per context dynamic (sub)slice power-gating Tvrtko Ursulin
2019-01-25 15:24 ` [PATCH 3/5] drm/i915: Add timeline barrier support Tvrtko Ursulin
2019-01-25 15:37 ` Chris Wilson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190130093416.3513-4-tvrtko.ursulin@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=Intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox