Introduce a new function to retiring all shadow PPGTTs of a vGPU.

The shadow PPPGTs of a vGPU need to be invalidated if a guest modifies the
virtual private PPAT since the mapping between the virtual PPAT indexes
and the shadow PPAT indexes will be re-built after a guest writes a new
virtual PPAT configruation.

Signed-off-by: Zhi Wang <zhi.a.w...@intel.com>
---
 drivers/gpu/drm/i915/gvt/gtt.c | 23 +++++++++++++++++++++++
 drivers/gpu/drm/i915/gvt/gtt.h |  1 +
 2 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c
index 6e19d7a..1d7077d 100644
--- a/drivers/gpu/drm/i915/gvt/gtt.c
+++ b/drivers/gpu/drm/i915/gvt/gtt.c
@@ -1745,6 +1745,11 @@ void intel_vgpu_unpin_mm(struct intel_vgpu_mm *mm)
                return;
 
        atomic_dec(&mm->pincount);
+
+       if (mm->need_rebuild) {
+               invalidate_mm(mm);
+               mm->need_rebuild = false;
+       }
 }
 
 /**
@@ -1798,6 +1803,24 @@ static int reclaim_one_mm(struct intel_gvt *gvt)
        return 0;
 }
 
+static void retire_vgpu_ppgtt_mm(struct intel_vgpu *vgpu)
+{
+       struct intel_vgpu_mm *mm;
+       struct list_head *pos;
+
+       list_for_each(pos, &vgpu->gtt.mm_list_head) {
+               mm = container_of(pos, struct intel_vgpu_mm, list);
+
+               if (mm->type != INTEL_GVT_MM_PPGTT)
+                       continue;
+               if (atomic_read(&mm->pincount)) {
+                       mm->need_rebuild = true;
+                       continue;
+               }
+               invalidate_mm(mm);
+       }
+}
+
 /*
  * GMA translation APIs.
  */
diff --git a/drivers/gpu/drm/i915/gvt/gtt.h b/drivers/gpu/drm/i915/gvt/gtt.h
index 6cd4fc7..a83d1f0 100644
--- a/drivers/gpu/drm/i915/gvt/gtt.h
+++ b/drivers/gpu/drm/i915/gvt/gtt.h
@@ -147,6 +147,7 @@ struct intel_vgpu_mm {
        int type;
        bool initialized;
        bool shadowed;
+       bool need_rebuild;
 
        int page_table_entry_type;
        u32 page_table_entry_size;
-- 
2.7.4

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

Reply via email to