Commit 0009e46c authored by Ben Widawsky's avatar Ben Widawsky Committed by Daniel Vetter

drm/i915: Track which ring a context ran on

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.

As a result, we no longer need to track which ring a context "belongs"
to, as it never really made much sense anyway.
Signed-off-by: default avatarBen Widawsky <ben@bwidawsk.net>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 67e3d297
...@@ -696,7 +696,7 @@ struct i915_hw_context { ...@@ -696,7 +696,7 @@ struct i915_hw_context {
bool is_initialized; bool is_initialized;
uint8_t remap_slice; uint8_t remap_slice;
struct drm_i915_file_private *file_priv; struct drm_i915_file_private *file_priv;
struct intel_ring_buffer *ring; struct intel_ring_buffer *last_ring;
struct drm_i915_gem_object *obj; struct drm_i915_gem_object *obj;
struct i915_ctx_hang_stats hang_stats; struct i915_ctx_hang_stats hang_stats;
......
...@@ -176,11 +176,6 @@ create_hw_context(struct drm_device *dev, ...@@ -176,11 +176,6 @@ create_hw_context(struct drm_device *dev,
goto err_out; goto err_out;
} }
/* The ring associated with the context object is handled by the normal
* object tracking code. We give an initial ring value simple to pass an
* assertion in the context switch code.
*/
ctx->ring = &dev_priv->ring[RCS];
list_add_tail(&ctx->link, &dev_priv->context_list); list_add_tail(&ctx->link, &dev_priv->context_list);
/* Default context will never have a file_priv */ /* Default context will never have a file_priv */
...@@ -208,7 +203,8 @@ create_hw_context(struct drm_device *dev, ...@@ -208,7 +203,8 @@ create_hw_context(struct drm_device *dev,
static inline bool is_default_context(struct i915_hw_context *ctx) static inline bool is_default_context(struct i915_hw_context *ctx)
{ {
return (ctx == ctx->ring->default_context); /* Cheap trick to determine default contexts */
return ctx->file_priv ? false : true;
} }
/** /**
...@@ -338,6 +334,7 @@ void i915_gem_context_fini(struct drm_device *dev) ...@@ -338,6 +334,7 @@ void i915_gem_context_fini(struct drm_device *dev)
i915_gem_context_unreference(ring->last_context); i915_gem_context_unreference(ring->last_context);
ring->default_context = NULL; ring->default_context = NULL;
ring->last_context = NULL;
} }
i915_gem_object_ggtt_unpin(dctx->obj); i915_gem_object_ggtt_unpin(dctx->obj);
...@@ -467,7 +464,7 @@ static int do_switch(struct intel_ring_buffer *ring, ...@@ -467,7 +464,7 @@ static int do_switch(struct intel_ring_buffer *ring,
BUG_ON(!i915_gem_obj_is_pinned(from->obj)); BUG_ON(!i915_gem_obj_is_pinned(from->obj));
} }
if (from == to && !to->remap_slice) if (from == to && from->last_ring == ring && !to->remap_slice)
return 0; return 0;
if (ring != &dev_priv->ring[RCS]) { if (ring != &dev_priv->ring[RCS]) {
...@@ -547,6 +544,7 @@ static int do_switch(struct intel_ring_buffer *ring, ...@@ -547,6 +544,7 @@ static int do_switch(struct intel_ring_buffer *ring,
i915_gem_context_reference(to); i915_gem_context_reference(to);
ring->last_context = to; ring->last_context = to;
to->is_initialized = true; to->is_initialized = true;
to->last_ring = ring;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment