Commit fb218f20 authored by Chris Wilson's avatar Chris Wilson

drm/i915/gt: Discard stale context state from across idling

Before we idle, on parking, we switch to the kernel context such that we
have a scratch context loaded while the GPU idle, protecting any
precious user state. Be paranoid and assume that the idle state may have
been trashed, and reset the kernel_context image after idling.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Imre Deak <imre.deak@intel.com>
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Reviewed-by: default avatarMika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200102131707.1463945-4-chris@chris-wilson.co.uk
parent 49a24e71
...@@ -20,6 +20,7 @@ static int __engine_unpark(struct intel_wakeref *wf) ...@@ -20,6 +20,7 @@ static int __engine_unpark(struct intel_wakeref *wf)
{ {
struct intel_engine_cs *engine = struct intel_engine_cs *engine =
container_of(wf, typeof(*engine), wakeref); container_of(wf, typeof(*engine), wakeref);
struct intel_context *ce;
void *map; void *map;
ENGINE_TRACE(engine, "\n"); ENGINE_TRACE(engine, "\n");
...@@ -34,6 +35,11 @@ static int __engine_unpark(struct intel_wakeref *wf) ...@@ -34,6 +35,11 @@ static int __engine_unpark(struct intel_wakeref *wf)
if (!IS_ERR_OR_NULL(map)) if (!IS_ERR_OR_NULL(map))
engine->pinned_default_state = map; engine->pinned_default_state = map;
/* Discard stale context state from across idling */
ce = engine->kernel_context;
if (ce)
ce->ops->reset(ce);
if (engine->unpark) if (engine->unpark)
engine->unpark(engine); engine->unpark(engine);
......
...@@ -213,16 +213,8 @@ int intel_gt_resume(struct intel_gt *gt) ...@@ -213,16 +213,8 @@ int intel_gt_resume(struct intel_gt *gt)
intel_llc_enable(&gt->llc); intel_llc_enable(&gt->llc);
for_each_engine(engine, gt, id) { for_each_engine(engine, gt, id) {
struct intel_context *ce;
intel_engine_pm_get(engine); intel_engine_pm_get(engine);
ce = engine->kernel_context;
if (ce) {
GEM_BUG_ON(!intel_context_is_pinned(ce));
ce->ops->reset(ce);
}
engine->serial++; /* kernel context lost */ engine->serial++; /* kernel context lost */
err = engine->resume(engine); err = engine->resume(engine);
......
...@@ -152,6 +152,10 @@ static int mock_context_pin(struct intel_context *ce) ...@@ -152,6 +152,10 @@ static int mock_context_pin(struct intel_context *ce)
return intel_context_active_acquire(ce); return intel_context_active_acquire(ce);
} }
static void mock_context_reset(struct intel_context *ce)
{
}
static const struct intel_context_ops mock_context_ops = { static const struct intel_context_ops mock_context_ops = {
.alloc = mock_context_alloc, .alloc = mock_context_alloc,
...@@ -161,6 +165,7 @@ static const struct intel_context_ops mock_context_ops = { ...@@ -161,6 +165,7 @@ static const struct intel_context_ops mock_context_ops = {
.enter = intel_context_enter_engine, .enter = intel_context_enter_engine,
.exit = intel_context_exit_engine, .exit = intel_context_exit_engine,
.reset = mock_context_reset,
.destroy = mock_context_destroy, .destroy = mock_context_destroy,
}; };
......
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