drm/i915: make intel_gvt_init() later instead of too early
authorZhenyu Wang <zhenyuw@linux.intel.com>
Fri, 13 Jan 2017 02:46:09 +0000 (10:46 +0800)
committerZhenyu Wang <zhenyuw@linux.intel.com>
Tue, 7 Feb 2017 09:21:06 +0000 (17:21 +0800)
Previously intel_gvt_init() was called very early even before
MMIO initialization which had several drawbacks:
- Have to handle MMIO access for initial MMIO state dump if golden
  state firmware is not available
- Hypervisor detection should depend on pvinfo only instead of detecting
  hypervisor status.
- Don't know hw resource size e.g aperture, ggtt size to determine
  for vGPU type, etc.

This trys to move intel_gvt_init() call late after required info
has already been initialized for GVT host.

Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/intel_gvt.c

index 4ae69ebe166e5f23c84779748c84af16f4f8143f..1dfc0b204a72997d3e0927c2fdf0c8efe2528186 100644 (file)
@@ -824,10 +824,6 @@ static int i915_driver_init_early(struct drm_i915_private *dev_priv,
        if (ret < 0)
                return ret;
 
-       ret = intel_gvt_init(dev_priv);
-       if (ret < 0)
-               goto err_workqueues;
-
        /* This must be called before any calls to HAS_PCH_* */
        intel_detect_pch(dev_priv);
 
@@ -841,7 +837,7 @@ static int i915_driver_init_early(struct drm_i915_private *dev_priv,
        intel_init_audio_hooks(dev_priv);
        ret = i915_gem_load_init(dev_priv);
        if (ret < 0)
-               goto err_gvt;
+               goto err_workqueues;
 
        intel_display_crc_init(dev_priv);
 
@@ -853,8 +849,6 @@ static int i915_driver_init_early(struct drm_i915_private *dev_priv,
 
        return 0;
 
-err_gvt:
-       intel_gvt_cleanup(dev_priv);
 err_workqueues:
        i915_workqueues_cleanup(dev_priv);
        return ret;
@@ -1077,6 +1071,10 @@ static int i915_driver_init_hw(struct drm_i915_private *dev_priv)
                        DRM_DEBUG_DRIVER("can't enable MSI");
        }
 
+       ret = intel_gvt_init(dev_priv);
+       if (ret)
+               goto out_ggtt;
+
        return 0;
 
 out_ggtt:
@@ -1290,6 +1288,8 @@ void i915_driver_unload(struct drm_device *dev)
 
        intel_display_power_get(dev_priv, POWER_DOMAIN_INIT);
 
+       intel_gvt_cleanup(dev_priv);
+
        i915_driver_unregister(dev_priv);
 
        drm_vblank_cleanup(dev);
index 290384e86c635c568689046cbfc4ce184f11661b..d23c0fcff7516a9f3df4363010e2c3dfa84e3c00 100644 (file)
@@ -67,6 +67,11 @@ int intel_gvt_init(struct drm_i915_private *dev_priv)
                return 0;
        }
 
+       if (intel_vgpu_active(dev_priv)) {
+               DRM_DEBUG_DRIVER("GVT-g is disabled for guest\n");
+               goto bail;
+       }
+
        if (!is_supported_device(dev_priv)) {
                DRM_DEBUG_DRIVER("Unsupported device. GVT-g is disabled\n");
                goto bail;