Skip to content

Commit

Permalink
drm/i915: Move fiddling with engine->last_retired_context
Browse files Browse the repository at this point in the history
Move the knowledge about resetting the current context tracking on the
engine from inside i915_gem_context.c into intel_engine_cs.c

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180517212633.24934-2-chris@chris-wilson.co.uk
  • Loading branch information
Chris Wilson committed May 18, 2018
1 parent 4e0d64d commit 01278cb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
12 changes: 2 additions & 10 deletions drivers/gpu/drm/i915/i915_gem_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,16 +514,8 @@ void i915_gem_contexts_lost(struct drm_i915_private *dev_priv)

lockdep_assert_held(&dev_priv->drm.struct_mutex);

for_each_engine(engine, dev_priv, id) {
engine->legacy_active_context = NULL;
engine->legacy_active_ppgtt = NULL;

if (!engine->last_retired_context)
continue;

intel_context_unpin(engine->last_retired_context, engine);
engine->last_retired_context = NULL;
}
for_each_engine(engine, dev_priv, id)
intel_engine_lost_context(engine);
}

void i915_gem_contexts_fini(struct drm_i915_private *i915)
Expand Down
23 changes: 23 additions & 0 deletions drivers/gpu/drm/i915/intel_engine_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,29 @@ void intel_engines_unpark(struct drm_i915_private *i915)
}
}

/**
* intel_engine_lost_context: called when the GPU is reset into unknown state
* @engine: the engine
*
* We have either reset the GPU or otherwise about to lose state tracking of
* the current GPU logical state (e.g. suspend). On next use, it is therefore
* imperative that we make no presumptions about the current state and load
* from scratch.
*/
void intel_engine_lost_context(struct intel_engine_cs *engine)
{
struct i915_gem_context *ctx;

lockdep_assert_held(&engine->i915->drm.struct_mutex);

engine->legacy_active_context = NULL;
engine->legacy_active_ppgtt = NULL;

ctx = fetch_and_zero(&engine->last_retired_context);
if (ctx)
intel_context_unpin(ctx, engine);
}

bool intel_engine_can_store_dword(struct intel_engine_cs *engine)
{
switch (INTEL_GEN(engine->i915)) {
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/i915/intel_ringbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,7 @@ bool intel_engine_is_idle(struct intel_engine_cs *engine);
bool intel_engines_are_idle(struct drm_i915_private *dev_priv);

bool intel_engine_has_kernel_context(const struct intel_engine_cs *engine);
void intel_engine_lost_context(struct intel_engine_cs *engine);

void intel_engines_park(struct drm_i915_private *i915);
void intel_engines_unpark(struct drm_i915_private *i915);
Expand Down

0 comments on commit 01278cb

Please sign in to comment.