[Intel-gfx] [PATCH 51/66] drm/i915: Track which ring a context ran on

Ben Widawsky ben at bwidawsk.net
Fri Jun 28 01:30:52 CEST 2013


Previously we dropped the association of a context to a ring. It is
however very important to know which ring a context ran on (we could
have reused the other member, but I was nitpicky).

This is very important when we switch address spaces, which unlike
context objects, do change per ring.

As an example, if we have:

        RCS   BCS
ctx            A
ctx      A
ctx      B
ctx            B

Without tracking the last ring B ran on, we wouldn't know to switch the
address space on BCS in the last row.

Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_drv.h         | 1 +
 drivers/gpu/drm/i915/i915_gem_context.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index fa8a432..b1b31c0 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -586,6 +586,7 @@ struct i915_hw_context {
 	struct i915_ctx_hang_stats hang_stats;
 
 	struct i915_hw_ppgtt ppgtt;
+	struct intel_ring_buffer *last_ring;
 };
 
 struct i915_fbc {
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index faddf43..e20ece6 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -535,7 +535,7 @@ static int do_switch(struct intel_ring_buffer *ring,
 		BUG_ON(from->obj->pin_count == 0);
 	}
 
-	if (from == to)
+	if (from == to && from->last_ring == ring)
 		return 0;
 
 	if (ring != &dev_priv->ring[RCS] && from) {
@@ -616,6 +616,7 @@ done:
 	i915_gem_context_reference(to);
 	ring->last_context = to;
 	to->is_initialized = true;
+	to->last_ring = ring;
 
 	return 0;
 }
-- 
1.8.3.1




More information about the Intel-gfx mailing list