drm/i915/gvt: Add gvt options sanitize function
authorChuanxiao Dong <chuanxiao.dong@intel.com>
Sat, 27 May 2017 09:44:17 +0000 (17:44 +0800)
committerJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Tue, 30 May 2017 12:59:47 +0000 (15:59 +0300)
The intel_gvt_sanitize_options will sanitize the GVT related
options before doing initialize the GVT.

Suggested-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/intel_gvt.c
drivers/gpu/drm/i915/intel_gvt.h

index 7b8c72776f46ce82271e04361fd220e032f0314f..3536f1a7f5dac14a39c96f06a0c4d22ccb11616c 100644 (file)
@@ -997,6 +997,8 @@ static void intel_sanitize_options(struct drm_i915_private *dev_priv)
        DRM_DEBUG_DRIVER("use GPU semaphores? %s\n", yesno(i915.semaphores));
 
        intel_uc_sanitize_options(dev_priv);
+
+       intel_gvt_sanitize_options(dev_priv);
 }
 
 /**
index e1ab6432a91464d1ed19c4fee4336c780532ac68..dde9c78325e436284b8ce3dacf581a7de49abcc7 100644 (file)
@@ -50,6 +50,32 @@ static bool is_supported_device(struct drm_i915_private *dev_priv)
        return false;
 }
 
+/**
+ * intel_gvt_sanitize_options - sanitize GVT related options
+ * @dev_priv: drm i915 private data
+ *
+ * This function is called at the i915 options sanitize stage.
+ */
+void intel_gvt_sanitize_options(struct drm_i915_private *dev_priv)
+{
+       if (!i915.enable_gvt)
+               return;
+
+       if (intel_vgpu_active(dev_priv)) {
+               DRM_INFO("GVT-g is disabled for guest\n");
+               goto bail;
+       }
+
+       if (!is_supported_device(dev_priv)) {
+               DRM_INFO("Unsupported device. GVT-g is disabled\n");
+               goto bail;
+       }
+
+       return;
+bail:
+       i915.enable_gvt = 0;
+}
+
 /**
  * intel_gvt_init - initialize GVT components
  * @dev_priv: drm i915 private data
@@ -69,16 +95,6 @@ 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;
-       }
-
        if (!i915.enable_execlists) {
                DRM_INFO("GPU guest virtualisation [GVT-g] disabled due to disabled execlist submission [i915.enable_execlists module parameter]\n");
                goto bail;
index 25df2d65b985cec58c5294cb9c91199e0d86177d..61b24647028286bd82e533a744ea461cef114f48 100644 (file)
@@ -32,6 +32,7 @@ void intel_gvt_cleanup(struct drm_i915_private *dev_priv);
 int intel_gvt_init_device(struct drm_i915_private *dev_priv);
 void intel_gvt_clean_device(struct drm_i915_private *dev_priv);
 int intel_gvt_init_host(void);
+void intel_gvt_sanitize_options(struct drm_i915_private *dev_priv);
 #else
 static inline int intel_gvt_init(struct drm_i915_private *dev_priv)
 {
@@ -40,6 +41,10 @@ static inline int intel_gvt_init(struct drm_i915_private *dev_priv)
 static inline void intel_gvt_cleanup(struct drm_i915_private *dev_priv)
 {
 }
+
+static inline void intel_gvt_sanitize_options(struct drm_i915_private *dev_priv)
+{
+}
 #endif
 
 #endif /* _INTEL_GVT_H_ */