Skip to contentSkip to conversation

drm/i915: Change context lifecycle

PATCH In review Nick Hoath 2 participants 2 messages Nov 9, 2015 – Nov 10, 2015

Subsystems (2)
lore
Share & tools
lore

Nick Hoath

author
#0 lore raw

PATCH 1/1 drm/i915: Change context lifecycle

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 saved.
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.
The refcount on the context also has to be extended to cover this new longer period.

Issue: VIZ-4277
Cc: Daniel Vetter <[email protected]>
Cc: David Gordon <[email protected]>
Cc: Chris Wilson <[email protected]>
Cc: Alex Dai <[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 | 58 +++++++++++++++++++++++++++++++++-------
 drivers/gpu/drm/i915/intel_lrc.h |  1 +
 4 files changed, 57 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 20cd6d8..778b14a 100644
@@ -884,6 +884,7 @@ struct intel_context {
 	struct {
 		struct drm_i915_gem_object *state;
 		struct intel_ringbuffer *ringbuf;
+		bool unsaved;
 		int pin_count;
 	} engine[I915_NUM_RINGS];
 
drivers/gpu/drm/i915/i915_gem.c +7 -0
index f1e3fde..273946d 100644
@@ -1385,6 +1385,13 @@ __i915_gem_request_retire__upto(struct drm_i915_gem_request *req)
 		tmp = list_first_entry(&engine->request_list,
 				       typeof(*tmp), list);
 
+		if (i915.enable_execlists) {
+			unsigned long flags;
+
+			spin_lock_irqsave(&engine->execlist_lock, flags);
+			intel_lr_context_complete_check(tmp);
+			spin_unlock_irqrestore(&engine->execlist_lock, flags);
+		}
 		i915_gem_request_retire(tmp);
 	} while (tmp != req);
 
drivers/gpu/drm/i915/intel_lrc.c +48 -10

86 lines not on this page · raw message

drivers/gpu/drm/i915/intel_lrc.h +1 -0
index 4e60d54..cbc42b8 100644
@@ -86,6 +86,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);
Signature · 6 lines
1.9.1

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

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 saved.
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.
The refcount on the context also has to be extended to cover this new longer period.

Still not right. You were closer with the active tracking. The code I sent last year fixed this by unifying the pin/active tracking of legacy and execlists by calling engine->pin_context() in i915_gem_request_alloc(), and then in the request commit we released the pin on the engine->last_context and replaced it with active tracking (or just unpinned the new context in request cancel).
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx