drm/i915: Fold vGPU active check into inner functions
authorZhi Wang <zhi.a.wang@intel.com>
Thu, 16 Jun 2016 12:06:59 +0000 (08:06 -0400)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 17 Jun 2016 18:44:29 +0000 (19:44 +0100)
v5:
- Let functions take struct drm_i915_private *. (Tvrtko)

- Fold vGPU related active check into the inner functions. (Kevin)

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Suggested-by: Kevin Tian <kevin.tian@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Zhi Wang <zhi.a.wang@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1466078825-6662-4-git-send-email-zhi.a.wang@intel.com
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
drivers/gpu/drm/i915/i915_gem_gtt.c
drivers/gpu/drm/i915/i915_vgpu.c
drivers/gpu/drm/i915/i915_vgpu.h

index 7a139a6d44874abc692f80cd64276671c2a3f7f3..5890017b9832a82c5d61e7141e4f07c1e3c356dc 100644 (file)
@@ -2794,11 +2794,9 @@ static int i915_gem_setup_global_gtt(struct drm_device *dev,
        i915_address_space_init(&ggtt->base, dev_priv);
        ggtt->base.total += PAGE_SIZE;
 
-       if (intel_vgpu_active(dev_priv)) {
-               ret = intel_vgt_balloon(dev);
-               if (ret)
-                       return ret;
-       }
+       ret = intel_vgt_balloon(dev_priv);
+       if (ret)
+               return ret;
 
        if (!HAS_LLC(dev))
                ggtt->base.mm.color_adjust = i915_gtt_color_adjust;
@@ -2898,8 +2896,7 @@ void i915_ggtt_cleanup_hw(struct drm_device *dev)
        i915_gem_cleanup_stolen(dev);
 
        if (drm_mm_initialized(&ggtt->base.mm)) {
-               if (intel_vgpu_active(dev_priv))
-                       intel_vgt_deballoon();
+               intel_vgt_deballoon(dev_priv);
 
                drm_mm_takedown(&ggtt->base.mm);
                list_del(&ggtt->base.global_link);
index c3c6c64e5f5ee068ff0a70eeec6673b5added093..f6acb5a0e7015f8112277c26002f1c4cbbcc85c3 100644 (file)
@@ -101,10 +101,13 @@ static struct _balloon_info_ bl_info;
  * This function is called to deallocate the ballooned-out graphic memory, when
  * driver is unloaded or when ballooning fails.
  */
-void intel_vgt_deballoon(void)
+void intel_vgt_deballoon(struct drm_i915_private *dev_priv)
 {
        int i;
 
+       if (!intel_vgpu_active(dev_priv))
+               return;
+
        DRM_DEBUG("VGT deballoon.\n");
 
        for (i = 0; i < 4; i++) {
@@ -177,9 +180,8 @@ static int vgt_balloon_space(struct drm_mm *mm,
  * Returns:
  * zero on success, non-zero if configuration invalid or ballooning failed
  */
-int intel_vgt_balloon(struct drm_device *dev)
+int intel_vgt_balloon(struct drm_i915_private *dev_priv)
 {
-       struct drm_i915_private *dev_priv = to_i915(dev);
        struct i915_ggtt *ggtt = &dev_priv->ggtt;
        unsigned long ggtt_end = ggtt->base.start + ggtt->base.total;
 
@@ -187,6 +189,9 @@ int intel_vgt_balloon(struct drm_device *dev)
        unsigned long unmappable_base, unmappable_size, unmappable_end;
        int ret;
 
+       if (!intel_vgpu_active(dev_priv))
+               return 0;
+
        mappable_base = I915_READ(vgtif_reg(avail_rs.mappable_gmadr.base));
        mappable_size = I915_READ(vgtif_reg(avail_rs.mappable_gmadr.size));
        unmappable_base = I915_READ(vgtif_reg(avail_rs.nonmappable_gmadr.base));
@@ -258,6 +263,6 @@ int intel_vgt_balloon(struct drm_device *dev)
 
 err:
        DRM_ERROR("VGT balloon fail\n");
-       intel_vgt_deballoon();
+       intel_vgt_deballoon(dev_priv);
        return ret;
 }
index 07e67d520273ab191db342b4c38c5f7d7a62c871..3c3b2d24e830447ff0023b47bf7a38d21f5048cc 100644 (file)
@@ -26,8 +26,8 @@
 
 #include "i915_pvinfo.h"
 
-extern void i915_check_vgpu(struct drm_i915_private *dev_priv);
-extern int intel_vgt_balloon(struct drm_device *dev);
-extern void intel_vgt_deballoon(void);
+void i915_check_vgpu(struct drm_i915_private *dev_priv);
+int intel_vgt_balloon(struct drm_i915_private *dev_priv);
+void intel_vgt_deballoon(struct drm_i915_private *dev_priv);
 
 #endif /* _I915_VGPU_H_ */