Skip to contentSkip to conversation

drm/i915: Extend LRC pinning to cover GPU context writeback

PATCH Superseded Nick Hoath 3 participants 3 messages Dec 18, 2015 – Dec 21, 2015

Subsystems (2)

v9 of 12 Superseded Latest is v12 →

lore
Share & tools
lore

Nick Hoath

author
#0 lore raw

PATCH v9 1/1 drm/i915: Extend LRC pinning to cover GPU context writeback

Use the first retired request on a new context to unpin the old context. This ensures that the hw context remains bound until it has been written back to by the GPU.
Now that the context is pinned until later in the request/context lifecycle, it no longer needs to be pinned from context_queue to retire_requests.
This fixes an issue with GuC submission where the GPU might not have finished writing back the context before it is unpinned. This results in a GPU hang.

v2: Moved the new pin to cover GuC submission (Alex Dai)
Moved the new unpin to request_retire to fix coverage leak
v3: Added switch to default context if freeing a still pinned
context just in case the hw was actually still using it
v4: Unwrapped context unpin to allow calling without a request
v5: Only create a switch to idle context if the ring doesn't
already have a request pending on it (Alex Dai)
Rename unsaved to dirty to avoid double negatives (Dave Gordon) Changed _no_req postfix to __ prefix for consistency (Dave Gordon) Split out per engine cleanup from context_free as it
was getting unwieldy
Corrected locking (Dave Gordon)
v6: Removed some bikeshedding (Mika Kuoppala)
Added explanation of the GuC hang that this fixes (Daniel Vetter)
v7: Removed extra per request pinning from ring reset code (Alex Dai)
Added forced ring unpin/clean in error case in context free (Alex Dai)
v8: Renamed lrc specific last_context to lrc_last_context as there
were some reset cases where the codepaths leaked (Mika Kuoppala) NULL'd last_context in reset case - there was a pointer leak if someone did reset->close context.
v9: Rebase over "Fix context/engine cleanup order"

Issue: VIZ-4277
Cc: Daniel Vetter <[email protected]>
Cc: David Gordon <[email protected]>
Cc: Chris Wilson <[email protected]>
Cc: Alex Dai <[email protected]>
Cc: Mika Kuoppala <[email protected]>

---
 drivers/gpu/drm/i915/i915_drv.h         |   1 +
 drivers/gpu/drm/i915/i915_gem.c         |   7 +-
 drivers/gpu/drm/i915/intel_lrc.c        | 146 ++++++++++++++++++++++++++------
 drivers/gpu/drm/i915/intel_lrc.h        |   1 +
 drivers/gpu/drm/i915/intel_ringbuffer.h |   1 +
 5 files changed, 124 insertions(+), 32 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 27bb401..2f6f411 100644
@@ -887,6 +887,7 @@ struct intel_context {
 	struct {
 		struct drm_i915_gem_object *state;
 		struct intel_ringbuffer *ringbuf;
+		bool dirty;
 		int pin_count;
 	} engine[I915_NUM_RINGS];
 
drivers/gpu/drm/i915/i915_gem.c +3 -4
index 517676a..69e904f 100644
@@ -1362,6 +1362,9 @@ static void i915_gem_request_retire(struct drm_i915_gem_request *request)
 {
 	trace_i915_gem_request_retire(request);
 
+	if (i915.enable_execlists)
+		intel_lr_context_complete_check(request);
+
 	/* We know the GPU must have read the request to have
 	 * sent us the seqno + interrupt, so use the position
 	 * of tail of the request to update the last known position
@@ -2772,10 +2775,6 @@ static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv,
 					struct drm_i915_gem_request,
 					execlist_link);
 			list_del(&submit_req->execlist_link);
-
-			if (submit_req->ctx != ring->default_context)
-				intel_lr_context_unpin(submit_req);
-
 			i915_gem_request_unreference(submit_req);
 		}
 		spin_unlock_irq(&ring->execlist_lock);
drivers/gpu/drm/i915/intel_lrc.c +118 -28

196 lines not on this page · raw message

drivers/gpu/drm/i915/intel_lrc.h +1 -0
index 0b821b9..fd1b6b4 100644
@@ -91,6 +91,7 @@ void intel_lr_context_reset(struct drm_device *dev,
 			struct intel_context *ctx);
 uint64_t intel_lr_context_descriptor(struct intel_context *ctx,
 				     struct intel_engine_cs *ring);
+void intel_lr_context_complete_check(struct drm_i915_gem_request *req);
 
 /* Execlists */
 int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlists);
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -0
index 49574ff..9bd98db 100644
@@ -275,6 +275,7 @@ struct  intel_engine_cs {
 				      u32 flush_domains);
 	int		(*emit_bb_start)(struct drm_i915_gem_request *req,
 					 u64 offset, unsigned dispatch_flags);
+	struct intel_context *lrc_last_context;
 
 	/**
 	 * List of objects currently involved in rendering from the
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

✗ failure: Fi.CI.BAT

== Summary ==

== Summary ==

HEAD is now at da33ddb drm-intel-nightly: 2015y-12m-18d-13h-53m-06s UTC integration manifest
Applying: drm/i915: Extend LRC pinning to cover GPU context writeback Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Patch failed at 0001 drm/i915: Extend LRC pinning to cover GPU context writeback

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw

Re: ✗ failure: Fi.CI.BAT

Quoted 7 lines · Patchwork

== Summary ==

HEAD is now at da33ddb drm-intel-nightly: 2015y-12m-18d-13h-53m-06s UTC integration manifest
Applying: drm/i915: Extend LRC pinning to cover GPU context writeback Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Patch failed at 0001 drm/i915: Extend LRC pinning to cover GPU context writeback

Dependent patches should be submitted as an entire series. -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx