Skip to contentSkip to conversation

drm/i915: Remove FIXME_lrc_ctx backpointer

RFC In review Nick Hoath 2 participants 2 messages Oct 15, 2014

Subsystems (2)
lore
Share & tools
lore

Nick Hoath

author
#0 lore raw

RFC 1/1 drm/i915: Remove FIXME_lrc_ctx backpointer

The first pass implementation of execlists required a backpointer to the context to be held in the intel_ringbuffer. However the context pointer is available higher in the call stack. Remove the backpointer from the ring buffer structure and instead pass it down through the call stack.

---
 drivers/gpu/drm/i915/i915_gem.c         |  7 ++--
 drivers/gpu/drm/i915/intel_lrc.c        | 65 ++++++++++++++++++++-------------
 drivers/gpu/drm/i915/intel_lrc.h        | 10 +++--
 drivers/gpu/drm/i915/intel_ringbuffer.h | 14 +++----
 4 files changed, 56 insertions(+), 40 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +4 -3
index e9c783d..724bbdf 100644
@@ -2322,6 +2322,7 @@ int __i915_add_request(struct intel_engine_cs *ring,
 	struct drm_i915_gem_request *request;
 	struct intel_ringbuffer *ringbuf;
 	u32 request_ring_position, request_start;
+	struct intel_context *ctx = NULL;
 	int ret;
 
 	request = ring->preallocated_lazy_request;
@@ -2329,7 +2330,7 @@ int __i915_add_request(struct intel_engine_cs *ring,
 		return -ENOMEM;
 
 	if (i915.enable_execlists) {
-		struct intel_context *ctx = request->ctx;
+		ctx = request->ctx;
 		ringbuf = ctx->engine[ring->id].ringbuf;
 	} else
 		ringbuf = ring->buffer;
@@ -2343,7 +2344,7 @@ int __i915_add_request(struct intel_engine_cs *ring,
 	 * what.
 	 */
 	if (i915.enable_execlists) {
-		ret = logical_ring_flush_all_caches(ringbuf);
+		ret = logical_ring_flush_all_caches(ringbuf, ctx);
 		if (ret)
 			return ret;
 	} else {
@@ -2360,7 +2361,7 @@ int __i915_add_request(struct intel_engine_cs *ring,
 	request_ring_position = intel_ring_get_tail(ringbuf);
 
 	if (i915.enable_execlists) {
-		ret = ring->emit_request(ringbuf);
+		ret = ring->emit_request(ringbuf, ctx);
 		if (ret)
 			return ret;
 	} else {
drivers/gpu/drm/i915/intel_lrc.c +39 -26

244 lines not on this page · raw message

drivers/gpu/drm/i915/intel_lrc.h +7 -3
index 33c3b4b..ee647db 100644
@@ -36,8 +36,10 @@ void intel_logical_ring_stop(struct intel_engine_cs *ring);
 void intel_logical_ring_cleanup(struct intel_engine_cs *ring);
 int intel_logical_rings_init(struct drm_device *dev);
 
-int logical_ring_flush_all_caches(struct intel_ringbuffer *ringbuf);
-void intel_logical_ring_advance_and_submit(struct intel_ringbuffer *ringbuf);
+int logical_ring_flush_all_caches(struct intel_ringbuffer *ringbuf,
+					   struct intel_context *ctx);
+void intel_logical_ring_advance_and_submit(struct intel_ringbuffer *ringbuf,
+					   struct intel_context *ctx);
 /**
  * intel_logical_ring_advance() - advance the ringbuffer tail
  * @ringbuf: Ringbuffer to advance.
@@ -59,7 +61,9 @@ static inline void intel_logical_ring_emit(struct intel_ringbuffer *ringbuf,
 	iowrite32(data, ringbuf->virtual_start + ringbuf->tail);
 	ringbuf->tail += 4;
 }
-int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf, int num_dwords);
+int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf,
+			     struct intel_context *ctx,
+			     int num_dwords);
 
 /* Logical Ring Contexts */
 int intel_lr_context_render_state_init(struct intel_engine_cs *ring,
drivers/gpu/drm/i915/intel_ringbuffer.h +6 -8
index 96479c8..5cd09d3 100644
@@ -99,13 +99,6 @@ struct intel_ringbuffer {
 
 	struct intel_engine_cs *ring;
 
-	/*
-	 * FIXME: This backpointer is an artifact of the history of how the
-	 * execlist patches came into being. It will get removed once the basic
-	 * code has landed.
-	 */
-	struct intel_context *FIXME_lrc_ctx;
-
 	u32 head;
 	u32 tail;
 	int space;
@@ -123,6 +116,8 @@ struct intel_ringbuffer {
 	u32 last_retired_head;
 };
 
+struct intel_context;
+
 struct  intel_engine_cs {
 	const char	*name;
 	enum intel_ring_id {
@@ -237,11 +232,14 @@ struct  intel_engine_cs {
 	struct list_head execlist_queue;
 	u8 next_context_status_buffer;
 	u32             irq_keep_mask; /* bitmask for interrupts that should not be masked */
-	int		(*emit_request)(struct intel_ringbuffer *ringbuf);
+	int		(*emit_request)(struct intel_ringbuffer *ringbuf,
+					struct intel_context *ctx);
 	int		(*emit_flush)(struct intel_ringbuffer *ringbuf,
+				      struct intel_context *ctx,
 				      u32 invalidate_domains,
 				      u32 flush_domains);
 	int		(*emit_bb_start)(struct intel_ringbuffer *ringbuf,
+					 struct intel_context *ctx,
 					 u64 offset, unsigned flags);
 
 	/**
Signature · 1 line
2.1.1
#1 lore raw
Quoted 4 lines · Nick Hoath

The first pass implementation of execlists required a backpointer to the context to be held in the intel_ringbuffer. However the context pointer is available higher in the call stack. Remove the backpointer from the ring buffer structure and instead pass it down through the call stack.

If you look at my fixes for execlist, you don't even need this. The only usecase I have for ring->ctx is in debugfs, where you don't have the information in the stack anyway.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre