Commit fe0c4935 authored by Chris Wilson's avatar Chris Wilson

drm/i915/execlists: Handle copying default context state for atomic reset

We want to be able to reset the GPU from inside a timer callback
(hardirq context). One step requires us to copy the default context
state over to the guilty context, which means we need to plan in advance
to have that object accessible from within an atomic context. The atomic
context prevents us from pinning the object or from peeking into the
shmemfs backing store (all may sleep), so we choose to pin the
default_state into memory when the engine becomes active. This
compromise allows us to swap out the default state when idle, when
required.

References: 5692251c ("drm/i915/lrc: Scrub the GPU state of the guilty hanging request")
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180518090212.5349-2-chris@chris-wilson.co.uk
parent d6d12ec0
...@@ -1091,6 +1091,11 @@ void intel_engines_park(struct drm_i915_private *i915) ...@@ -1091,6 +1091,11 @@ void intel_engines_park(struct drm_i915_private *i915)
if (engine->park) if (engine->park)
engine->park(engine); engine->park(engine);
if (engine->pinned_default_state) {
i915_gem_object_unpin_map(engine->default_state);
engine->pinned_default_state = NULL;
}
i915_gem_batch_pool_fini(&engine->batch_pool); i915_gem_batch_pool_fini(&engine->batch_pool);
engine->execlists.no_priolist = false; engine->execlists.no_priolist = false;
} }
...@@ -1108,6 +1113,16 @@ void intel_engines_unpark(struct drm_i915_private *i915) ...@@ -1108,6 +1113,16 @@ void intel_engines_unpark(struct drm_i915_private *i915)
enum intel_engine_id id; enum intel_engine_id id;
for_each_engine(engine, i915, id) { for_each_engine(engine, i915, id) {
void *map;
/* Pin the default state for fast resets from atomic context. */
map = NULL;
if (engine->default_state)
map = i915_gem_object_pin_map(engine->default_state,
I915_MAP_WB);
if (!IS_ERR_OR_NULL(map))
engine->pinned_default_state = map;
if (engine->unpark) if (engine->unpark)
engine->unpark(engine); engine->unpark(engine);
......
...@@ -1965,17 +1965,10 @@ static void execlists_reset(struct intel_engine_cs *engine, ...@@ -1965,17 +1965,10 @@ static void execlists_reset(struct intel_engine_cs *engine,
* to recreate its own state. * to recreate its own state.
*/ */
regs = request->hw_context->lrc_reg_state; regs = request->hw_context->lrc_reg_state;
if (engine->default_state) { if (engine->pinned_default_state) {
void *defaults; memcpy(regs, /* skip restoring the vanilla PPHWSP */
engine->pinned_default_state + LRC_STATE_PN * PAGE_SIZE,
defaults = i915_gem_object_pin_map(engine->default_state, engine->context_size - PAGE_SIZE);
I915_MAP_WB);
if (!IS_ERR(defaults)) {
memcpy(regs, /* skip restoring the vanilla PPHWSP */
defaults + LRC_STATE_PN * PAGE_SIZE,
engine->context_size - PAGE_SIZE);
i915_gem_object_unpin_map(engine->default_state);
}
} }
execlists_init_reg_state(regs, execlists_init_reg_state(regs,
request->gem_context, engine, request->ring); request->gem_context, engine, request->ring);
......
...@@ -342,6 +342,7 @@ struct intel_engine_cs { ...@@ -342,6 +342,7 @@ struct intel_engine_cs {
struct i915_timeline timeline; struct i915_timeline timeline;
struct drm_i915_gem_object *default_state; struct drm_i915_gem_object *default_state;
void *pinned_default_state;
atomic_t irq_count; atomic_t irq_count;
unsigned long irq_posted; unsigned long irq_posted;
......
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