diff mbox

[51/66] drm/i915: Track which ring a context ran on

Message ID 1372375867-1003-52-git-send-email-ben@bwidawsk.net (mailing list archive)
State New, archived
Headers show

Commit Message

Ben Widawsky June 27, 2013, 11:30 p.m. UTC
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@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 mbox

Patch

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;
 }