drm/i915: Make LRC (un)pinning work on context and engine
Subsystems (2)
PATCH 1/4 drm/i915: Make LRC (un)pinning work on context and engine
From: Tvrtko Ursulin <[email protected]>
Previously intel_lr_context_(un)pin were operating on requests which is in conflict with their names.
If we make them take a context and an engine, it makes the names make more sense and it also makes future fixes possible.
v2: Rebase for default_context/kernel_context change.
--- drivers/gpu/drm/i915/i915_gem.c | 2 +- drivers/gpu/drm/i915/intel_lrc.c | 49 ++++++++++++++++++++-------------------- drivers/gpu/drm/i915/intel_lrc.h | 3 ++- 3 files changed, 28 insertions(+), 26 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -1
@@ -2680,7 +2680,7 @@ void i915_gem_request_free(struct kref *req_ref)if (ctx) {if (i915.enable_execlists && ctx != req->i915->kernel_context) -intel_lr_context_unpin (req); +intel_lr_context_unpin (ctx, req->ring);i915_gem_context_unreference (ctx); }
drivers/gpu/drm/i915/intel_lrc.c +25 -24
109 lines not on this page · raw message
drivers/gpu/drm/i915/intel_lrc.h +2 -1
@@ -101,7 +101,8 @@ void intel_lr_context_free(struct intel_context *ctx);uint32_t intel_lr_context_size (struct intel_engine_cs *ring);int intel_lr_context_deferred_alloc (struct intel_context *ctx,struct intel_engine_cs *ring); -void intel_lr_context_unpin (struct drm_i915_gem_request *req); +void intel_lr_context_unpin (struct intel_context *ctx, +struct intel_engine_cs *engine);void intel_lr_context_reset (struct drm_device *dev,struct intel_context *ctx); uint64_t intel_lr_context_descriptor(struct intel_context *ctx,
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/4 drm/i915: Make LRC pinning own a reference to the context
From: Tvrtko Ursulin <[email protected]>
Will simplify the following fix and sounds logical.
v2: Add some whitespace to separate logic better. (Chris Wilson)
--- drivers/gpu/drm/i915/intel_lrc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/i915/intel_lrc.c +4 -0
@@ -1116,6 +1116,8 @@ static int intel_lr_context_pin(struct intel_context *ctx, ret =intel_lr_context_do_pin (ctx, engine);if (ret) goto reset_pin_count; + +i915_gem_context_reference (ctx); }return ret;
@@ -1141,6 +1143,8 @@ void intel_lr_context_unpin(struct intel_context *ctx, ctx->engine[engine->id].lrc_vma =NULL ; ctx->engine[engine->id].lrc_desc =0 ; ctx->engine[engine->id].lrc_reg_state =NULL ; + +i915_gem_context_unreference (ctx); } }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/4 drm/i915: Extract context unpinning to its own function
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
Will enable cleaner implementation of a following fix and easier code unification in the future.
Idea and code by Chris Wilson.
v2: Do not return before last_contexts on engines are unpinned.
--- drivers/gpu/drm/i915/i915_gem_context.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +12 -18
@@ -321,6 +321,14 @@ err_destroy:return ERR_PTR (ret); } +static void i915_gem_context_unpin (struct intel_context *ctx, +struct intel_engine_cs *engine) +{ +if (engine->id ==RCS && ctx->legacy_hw_ctx.rcs_state) +i915_gem_object_ggtt_unpin (ctx->legacy_hw_ctx.rcs_state); +i915_gem_context_unreference (ctx); +} +void i915_gem_context_reset (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;
@@ -329,22 +337,15 @@ void i915_gem_context_reset(struct drm_device *dev)if (i915.enable_execlists) {struct intel_context *ctx; -list_for_each_entry (ctx, &dev_priv->context_list, link) { +list_for_each_entry (ctx, &dev_priv->context_list, link)intel_lr_context_reset (dev, ctx); - } - -return ; }for (i =0 ; i <I915_NUM_RINGS ; i++) {struct intel_engine_cs *ring = &dev_priv->ring[i]; -struct intel_context *lctx = ring->last_context; - -if (lctx) { -if (lctx->legacy_hw_ctx.rcs_state && i ==RCS ) -i915_gem_object_ggtt_unpin (lctx->legacy_hw_ctx.rcs_state); -i915_gem_context_unreference (lctx); +if (ring->last_context) { +i915_gem_context_unpin (ring->last_context, ring); ring->last_context =NULL ; } }
@@ -417,13 +418,6 @@ void i915_gem_context_fini(struct drm_device *dev)* to offset the do_switch part, so that i915_gem_context_unreference() * can then free the base object correctly. */ WARN_ON (!dev_priv->ring[RCS ].last_context); -if (dev_priv->ring[RCS ].last_context == dctx) { -/* Fake switch to NULL context */ -WARN_ON (dctx->legacy_hw_ctx.rcs_state->active); -i915_gem_object_ggtt_unpin (dctx->legacy_hw_ctx.rcs_state); -i915_gem_context_unreference (dctx); - dev_priv->ring[RCS ].last_context =NULL ; - }i915_gem_object_ggtt_unpin (dctx->legacy_hw_ctx.rcs_state); }
@@ -432,7 +426,7 @@ void i915_gem_context_fini(struct drm_device *dev)struct intel_engine_cs *ring = &dev_priv->ring[i];if (ring->last_context) { -i915_gem_context_unreference (ring->last_context); +i915_gem_context_unpin (ring->last_context, ring); ring->last_context =NULL ; } }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/4 drm/i915: Fix premature LRC unpin in GuC mode
In reply to Tvrtko UrsulinFrom: Tvrtko Ursulin <[email protected]>
In GuC mode LRC pinning lifetime depends exclusively on the request liftime. Since that is terminated by the seqno update that opens up a race condition between GPU finishing writing out the context image and the driver unpinning the LRC.
To extend the LRC lifetime we will employ a similar approach to what legacy ringbuffer submission does.
We will start tracking the last submitted context per engine and keep it pinned until it is replaced by another one.
Note that the driver unload path is a bit fragile and could benefit greatly from efforts to unify the legacy and exec list submission code paths.
At the moment i915_gem_context_fini has special casing for the two which are potentialy not needed, and also depends on i915_gem_cleanup_ringbuffer running before itself.
v2:
* Move pinning into engine->emit_request and actually fix the reference/unreference logic. (Chris Wilson)
* ring->dev can be NULL on driver unload so use a different route towards it.
v3:
* Rebase.
* Handle the reset path. (Chris Wilson)
* Exclude default context from the pinning - it is impossible to get it right before default context special casing in general is eliminated.
v4:
* Rebased & moved context tracking to
intel_logical_ring_advance_and_submit.
Issue: VIZ-4277
Cc: Chris Wilson <[email protected]>
Cc: Nick Hoath <[email protected]>
--- drivers/gpu/drm/i915/i915_gem_context.c | 10 +++++++--- drivers/gpu/drm/i915/intel_lrc.c | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +7 -3
@@ -324,9 +324,13 @@ err_destroy:static void i915_gem_context_unpin (struct intel_context *ctx,struct intel_engine_cs *engine) { -if (engine->id ==RCS && ctx->legacy_hw_ctx.rcs_state) -i915_gem_object_ggtt_unpin (ctx->legacy_hw_ctx.rcs_state); -i915_gem_context_unreference (ctx); +if (i915.enable_execlists) { +intel_lr_context_unpin (ctx, engine); + }else { +if (engine->id ==RCS && ctx->legacy_hw_ctx.rcs_state) +i915_gem_object_ggtt_unpin (ctx->legacy_hw_ctx.rcs_state); +i915_gem_context_unreference (ctx); + } }void i915_gem_context_reset (struct drm_device *dev)
drivers/gpu/drm/i915/intel_lrc.c +14 -2
@@ -765,6 +765,7 @@ intel_logical_ring_advance_and_submit(struct drm_i915_gem_request *request) {struct intel_ringbuffer *ringbuf = request->ringbuf;struct drm_i915_private *dev_priv = request->i915; +struct intel_engine_cs *engine = request->ring;intel_logical_ring_advance (ringbuf); request->tail = ringbuf->tail;
@@ -779,9 +780,20 @@ intel_logical_ring_advance_and_submit(struct drm_i915_gem_request *request)intel_logical_ring_emit (ringbuf,MI_NOOP );intel_logical_ring_advance (ringbuf); -if (intel_ring_stopped (request->ring)) +if (intel_ring_stopped (engine))return 0 ; +if (engine->last_context != request->ctx) { +if (engine->last_context) +intel_lr_context_unpin (engine->last_context, engine); +if (request->ctx != request->i915->kernel_context) { +intel_lr_context_pin (request->ctx, engine); + engine->last_context = request->ctx; + }else { + engine->last_context =NULL ; + } + } +if (dev_priv->guc.execbuf_client)i915_guc_submit (dev_priv->guc.execbuf_client, request);else
@@ -1131,7 +1143,7 @@ void intel_lr_context_unpin(struct intel_context *ctx, {struct drm_i915_gem_object *ctx_obj = ctx->engine[engine->id].state; -WARN_ON (!mutex_is_locked (&engine->dev->struct_mutex)); +WARN_ON (!mutex_is_locked (&ctx->i915->dev->struct_mutex));if (WARN_ON_ONCE (!ctx_obj))return ;
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 9 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Previously intel_lr_context_(un)pin were operating on requests which is in conflict with their names.
If we make them take a context and an engine, it makes the names make more sense and it also makes future fixes possible.
v2: Rebase for default_context/kernel_context change.
Series re-sent for CI only.
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: failure for series starting with [1/4] drm/i915: Make LRC (un)pinning work on context and engine
In reply to Tvrtko Ursulin== Summary ==
== Summary ==
Series 2896v1 Series without cover letter
http://patchwork.freedesktop.org/api/1.0/series/2896/revisions/1/mbox/
Test kms_flip:
Subgroup basic-flip-vs-modeset:
pass -> DMESG-WARN (ilk-hp8440p) UNSTABLEbdw-nuci7 total:156 pass:147 dwarn:0 dfail:0 fail:0 skip:9 bdw-ultra total:159 pass:153 dwarn:0 dfail:0 fail:0 skip:6 bsw-nuc-2 total:159 pass:135 dwarn:0 dfail:0 fail:0 skip:24 byt-nuc total:159 pass:142 dwarn:0 dfail:0 fail:0 skip:17 hsw-brixbox total:159 pass:152 dwarn:0 dfail:0 fail:0 skip:7 hsw-gt2 total:159 pass:155 dwarn:0 dfail:0 fail:0 skip:4 ilk-hp8440p total:159 pass:113 dwarn:1 dfail:0 fail:1 skip:44 ivb-t430s total:159 pass:151 dwarn:0 dfail:0 fail:0 skip:8 snb-dellxps total:159 pass:141 dwarn:0 dfail:0 fail:0 skip:18 snb-x220t total:159 pass:141 dwarn:0 dfail:0 fail:1 skip:17
HANGED skl-i5k-2 in igt@gem_sync@basic-blt
Results at /archive/results/CI_IGT_test/Patchwork_1309/
b3f8ad64bc71f6236f05c2e9f4ad49a61745869a drm-intel-nightly: 2016y-01m-28d-10h-26m-23s UTC integration manifest b8f13982bcce1baef100ec7f9b18336b9608a2fb drm/i915: Fix premature LRC unpin in GuC mode 5723d041e5492172cc019b8cb288500407160d1d drm/i915: Extract context unpinning to its own function 7659aab9d760aef74f244702c7b51ada6fcfc9dc drm/i915: Make LRC pinning own a reference to the context 171c49d3242038c5831e1cb96a50c77722bac34d drm/i915: Make LRC (un)pinning work on context and engine
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: ✗ Fi.CI.BAT: failure for series starting with [1/4] drm/i915: Make LRC (un)pinning work on context and engine
Quoted 8 lines · Patchwork
== Summary ==
Series 2896v1 Series without cover letter
http://patchwork.freedesktop.org/api/1.0/series/2896/revisions/1/mbox/Test
kms_flip:Subgroup basic-flip-vs-modeset: pass -> DMESG-WARN (ilk-hp8440p) UNSTABLE
Known and unrelated issue https://bugs.freedesktop.org/show_bug.cgi?id=93787
Regards,
Tvrtko
Quoted 13 lines
bdw-nuci7 total:156 pass:147 dwarn:0 dfail:0 fail:0 skip:9 bdw-ultra total:159 pass:153 dwarn:0 dfail:0 fail:0 skip:6 bsw-nuc-2 total:159 pass:135 dwarn:0 dfail:0 fail:0 skip:24 byt-nuc total:159 pass:142 dwarn:0 dfail:0 fail:0 skip:17 hsw-brixbox total:159 pass:152 dwarn:0 dfail:0 fail:0 skip:7 hsw-gt2 total:159 pass:155 dwarn:0 dfail:0 fail:0 skip:4 ilk-hp8440p total:159 pass:113 dwarn:1 dfail:0 fail:1 skip:44 ivb-t430s total:159 pass:151 dwarn:0 dfail:0 fail:0 skip:8 snb-dellxps total:159 pass:141 dwarn:0 dfail:0 fail:0 skip:18 snb-x220t total:159 pass:141 dwarn:0 dfail:0 fail:1 skip:17HANGED skl-i5k-2 in igt@gem_sync@basic-blt
Quoted 9 lines
Results at /archive/results/CI_IGT_test/Patchwork_1309/
b3f8ad64bc71f6236f05c2e9f4ad49a61745869adrm-intel-nightly: 2016y-01m-28d-10h-26m-23s UTC integration manifestb8f13982bcce1baef100ec7f9b18336b9608a2fbdrm/i915: Fix premature LRC unpin in GuC mode5723d041e5492172cc019b8cb288500407160d1ddrm/i915: Extract context unpinning to its own function7659aab9d760aef74f244702c7b51ada6fcfc9dcdrm/i915: Make LRC pinning own a reference to the context171c49d3242038c5831e1cb96a50c77722bac34ddrm/i915: Make LRC (un)pinning work on context and engine
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx