Move our "wait for the PD load to complete" paranoia before the
MI_SET_CONTEXT just in case the context restore tries to access local
addresses.

Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk>
---
 .../gpu/drm/i915/gt/intel_ring_submission.c   | 28 +++++++++----------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_ring_submission.c 
b/drivers/gpu/drm/i915/gt/intel_ring_submission.c
index f977fc27b001..dcdeef0a776f 100644
--- a/drivers/gpu/drm/i915/gt/intel_ring_submission.c
+++ b/drivers/gpu/drm/i915/gt/intel_ring_submission.c
@@ -1591,24 +1591,11 @@ static int switch_context(struct i915_request *rq)
        GEM_BUG_ON(HAS_EXECLISTS(rq->i915));
 
        if (vm) {
-               ret = load_pd_dir(rq, i915_vm_to_ppgtt(vm));
-               if (ret)
-                       return ret;
-       }
-
-       if (ce->state) {
-               GEM_BUG_ON(rq->engine->id != RCS0);
-
-               if (!rq->engine->default_state)
-                       hw_flags = MI_RESTORE_INHIBIT;
+               struct intel_engine_cs *engine = rq->engine;
 
-               ret = mi_set_context(rq, hw_flags);
+               ret = load_pd_dir(rq, i915_vm_to_ppgtt(vm));
                if (ret)
                        return ret;
-       }
-
-       if (vm) {
-               struct intel_engine_cs *engine = rq->engine;
 
                ret = engine->emit_flush(rq, EMIT_INVALIDATE);
                if (ret)
@@ -1635,6 +1622,17 @@ static int switch_context(struct i915_request *rq)
                        return ret;
        }
 
+       if (ce->state) {
+               GEM_BUG_ON(rq->engine->id != RCS0);
+
+               if (!rq->engine->default_state)
+                       hw_flags = MI_RESTORE_INHIBIT;
+
+               ret = mi_set_context(rq, hw_flags);
+               if (ret)
+                       return ret;
+       }
+
        ret = remap_l3(rq);
        if (ret)
                return ret;
-- 
2.24.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to