From: Yu Zhang <yu.c.zh...@intel.com>

The current XenGT only supports alias ppgtt. And the emulation
is done in XenGT host by first trapping PP_DIR_BASE mmio
accesses. Updating PP_DIR_BASE by using instructions such as
MI_LOAD_REGISTER_IMM are hard to emulate and are not supported
in current XenGT. Therefore this patch also added a new callback
routine - vgpu_mm_switch() to set the PP_DIR_BASE by mmio writes.

Signed-off-by: Yu Zhang <yu.c.zh...@intel.com>
Signed-off-by: Jike Song <jike.s...@intel.com>
---
 drivers/gpu/drm/i915/i915_dma.c     |  5 +++++
 drivers/gpu/drm/i915/i915_gem_gtt.c | 14 ++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index a3fe7c0..63dccd2 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1746,6 +1746,11 @@ int i915_driver_load(struct drm_device *dev, unsigned 
long flags)
                i915.enable_fbc = 0;
 
                intel_vgpu_reg_write_init(dev);
+
+               if (USES_FULL_PPGTT(dev)) {
+                       DRM_INFO("Only support alias ppgtt for now in VM.\n");
+                       i915.enable_ppgtt = 1;
+               }
        }
 
        intel_irq_init(dev);
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c 
b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 368262d..e61d66f 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -898,6 +898,17 @@ static int hsw_mm_switch(struct i915_hw_ppgtt *ppgtt,
        return 0;
 }
 
+static int vgpu_mm_switch(struct i915_hw_ppgtt *ppgtt,
+                        struct intel_engine_cs *ring)
+{
+       struct drm_device *dev = ppgtt->base.dev;
+       struct drm_i915_private *dev_priv = dev->dev_private;
+
+       I915_WRITE(RING_PP_DIR_DCLV(ring), PP_DIR_DCLV_2G);
+       I915_WRITE(RING_PP_DIR_BASE(ring), get_pd_offset(ppgtt));
+       return 0;
+}
+
 static int gen7_mm_switch(struct i915_hw_ppgtt *ppgtt,
                          struct intel_engine_cs *ring)
 {
@@ -1224,6 +1235,9 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt)
        } else
                BUG();
 
+       if (intel_vgpu_active(dev))
+               ppgtt->switch_mm = vgpu_mm_switch;
+
        ret = gen6_ppgtt_alloc(ppgtt);
        if (ret)
                return ret;
-- 
1.9.1

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

Reply via email to