drm/i915: Move over to intel_context_lookup()
In preparation for an ever growing number of engines and so ever increasing static array of HW contexts within the GEM context, move the array over to an rbtree, allocated upon first use. Unfortunately, this imposes an rbtree lookup at a few frequent callsites, but we should be able to mitigate those by moving over to using the HW context as our primary type and so only incur the lookup on the boundary with the user GEM context and engines. v2: Check for no HW context in guc_stage_desc_init Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190308132522.21573-4-chris@chris-wilson.co.uk
This commit is contained in:
@@ -1349,15 +1349,20 @@ intel_ring_free(struct intel_ring *ring)
|
||||
kfree(ring);
|
||||
}
|
||||
|
||||
static void __ring_context_fini(struct intel_context *ce)
|
||||
{
|
||||
GEM_BUG_ON(i915_gem_object_is_active(ce->state->obj));
|
||||
i915_gem_object_put(ce->state->obj);
|
||||
}
|
||||
|
||||
static void ring_context_destroy(struct intel_context *ce)
|
||||
{
|
||||
GEM_BUG_ON(ce->pin_count);
|
||||
|
||||
if (!ce->state)
|
||||
return;
|
||||
if (ce->state)
|
||||
__ring_context_fini(ce);
|
||||
|
||||
GEM_BUG_ON(i915_gem_object_is_active(ce->state->obj));
|
||||
i915_gem_object_put(ce->state->obj);
|
||||
intel_context_free(ce);
|
||||
}
|
||||
|
||||
static int __context_pin_ppgtt(struct i915_gem_context *ctx)
|
||||
@@ -1552,7 +1557,11 @@ err:
|
||||
static struct intel_context *
|
||||
ring_context_pin(struct intel_engine_cs *engine, struct i915_gem_context *ctx)
|
||||
{
|
||||
struct intel_context *ce = to_intel_context(ctx, engine);
|
||||
struct intel_context *ce;
|
||||
|
||||
ce = intel_context_instance(ctx, engine);
|
||||
if (IS_ERR(ce))
|
||||
return ce;
|
||||
|
||||
lockdep_assert_held(&ctx->i915->drm.struct_mutex);
|
||||
|
||||
@@ -1754,8 +1763,8 @@ static inline int mi_set_context(struct i915_request *rq, u32 flags)
|
||||
* placeholder we use to flush other contexts.
|
||||
*/
|
||||
*cs++ = MI_SET_CONTEXT;
|
||||
*cs++ = i915_ggtt_offset(to_intel_context(i915->kernel_context,
|
||||
engine)->state) |
|
||||
*cs++ = i915_ggtt_offset(intel_context_lookup(i915->kernel_context,
|
||||
engine)->state) |
|
||||
MI_MM_SPACE_GTT |
|
||||
MI_RESTORE_INHIBIT;
|
||||
}
|
||||
|
Reference in New Issue
Block a user