drm/i915/gvt: skip populate shadow context if guest context not changed
[sfrench/cifs-2.6.git] / drivers / gpu / drm / i915 / gvt / gtt.c
index f6f2ab2683f78255e9fd05e17b8d508b65f057fe..dffd4b79b9a67d746889f629e149417d9808a15a 100644 (file)
@@ -2337,12 +2337,27 @@ int intel_vgpu_emulate_ggtt_mmio_write(struct intel_vgpu *vgpu,
 {
        const struct intel_gvt_device_info *info = &vgpu->gvt->device_info;
        int ret;
+       struct intel_vgpu_submission *s = &vgpu->submission;
+       struct intel_engine_cs *engine;
+       int i;
 
        if (bytes != 4 && bytes != 8)
                return -EINVAL;
 
        off -= info->gtt_start_offset;
        ret = emulate_ggtt_mmio_write(vgpu, off, p_data, bytes);
+
+       /* if ggtt of last submitted context is written,
+        * that context is probably got unpinned.
+        * Set last shadowed ctx to invalid.
+        */
+       for_each_engine(engine, vgpu->gvt->gt, i) {
+               if (!s->last_ctx[i].valid)
+                       continue;
+
+               if (s->last_ctx[i].lrca == (off >> info->gtt_entry_size_shift))
+                       s->last_ctx[i].valid = false;
+       }
        return ret;
 }