]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915: Consolidate #ifdef CONFIG_INTEL_IOMMU
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 25 May 2017 12:16:12 +0000 (13:16 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 25 May 2017 20:51:49 +0000 (21:51 +0100)
We depend on intel_iommu_gfx_mapped for various workarounds, but that is
only available under an #ifdef CONFIG_INTEL_IOMMU. Refactor all the
cut-and-paste ifdefs to a common routine.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/20170525121612.2190-1-chris@chris-wilson.co.uk
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_gtt.c
drivers/gpu/drm/i915/i915_gem_stolen.c
drivers/gpu/drm/i915/intel_fbc.c

index a5a01b683d48be7d4007cecb5c8838f50f09fbf5..9ba22427c05ca564579a8afe7a598d826fdf6487 100644 (file)
@@ -2997,23 +2997,24 @@ intel_info(const struct drm_i915_private *dev_priv)
 
 #include "i915_trace.h"
 
-static inline bool intel_scanout_needs_vtd_wa(struct drm_i915_private *dev_priv)
+static inline bool intel_vtd_active(void)
 {
 #ifdef CONFIG_INTEL_IOMMU
-       if (INTEL_GEN(dev_priv) >= 6 && intel_iommu_gfx_mapped)
+       if (intel_iommu_gfx_mapped)
                return true;
 #endif
        return false;
 }
 
+static inline bool intel_scanout_needs_vtd_wa(struct drm_i915_private *dev_priv)
+{
+       return INTEL_GEN(dev_priv) >= 6 && intel_vtd_active();
+}
+
 static inline bool
 intel_ggtt_update_needs_vtd_wa(struct drm_i915_private *dev_priv)
 {
-#ifdef CONFIG_INTEL_IOMMU
-       if (IS_BROXTON(dev_priv) && intel_iommu_gfx_mapped)
-               return true;
-#endif
-       return false;
+       return IS_BROXTON(dev_priv) && intel_vtd_active();
 }
 
 int intel_sanitize_enable_ppgtt(struct drm_i915_private *dev_priv,
index 0680bd2e635a0afeee4708fb29c1c70bc32ce0d9..7572dcdf4745d0627d9db9d107db9ed8d1583047 100644 (file)
@@ -4728,11 +4728,9 @@ bool intel_sanitize_semaphores(struct drm_i915_private *dev_priv, int value)
        if (value >= 0)
                return value;
 
-#ifdef CONFIG_INTEL_IOMMU
        /* Enable semaphores on SNB when IO remapping is off */
-       if (INTEL_INFO(dev_priv)->gen == 6 && intel_iommu_gfx_mapped)
+       if (IS_GEN6(dev_priv) && intel_vtd_active())
                return false;
-#endif
 
        return true;
 }
index 93f11c7ac162807b8b5add44c13a0c4ff04ff65e..f52068aee24736f4c0040e5f1f8ae97484812f9b 100644 (file)
@@ -166,13 +166,11 @@ int intel_sanitize_enable_ppgtt(struct drm_i915_private *dev_priv,
        if (enable_ppgtt == 3 && has_full_48bit_ppgtt)
                return 3;
 
-#ifdef CONFIG_INTEL_IOMMU
        /* Disable ppgtt on SNB if VT-d is on. */
-       if (IS_GEN6(dev_priv) && intel_iommu_gfx_mapped) {
+       if (IS_GEN6(dev_priv) && intel_vtd_active()) {
                DRM_INFO("Disabling PPGTT because VT-d is on\n");
                return 0;
        }
-#endif
 
        /* Early VLV doesn't have this */
        if (IS_VALLEYVIEW(dev_priv) && dev_priv->drm.pdev->revision < 0xb) {
@@ -1990,14 +1988,10 @@ void i915_ppgtt_release(struct kref *kref)
  */
 static bool needs_idle_maps(struct drm_i915_private *dev_priv)
 {
-#ifdef CONFIG_INTEL_IOMMU
        /* Query intel_iommu to see if we need the workaround. Presumably that
         * was loaded first.
         */
-       if (IS_GEN5(dev_priv) && IS_MOBILE(dev_priv) && intel_iommu_gfx_mapped)
-               return true;
-#endif
-       return false;
+       return IS_GEN5(dev_priv) && IS_MOBILE(dev_priv) && intel_vtd_active();
 }
 
 void i915_check_and_clear_faults(struct drm_i915_private *dev_priv)
@@ -3037,10 +3031,8 @@ int i915_ggtt_probe_hw(struct drm_i915_private *dev_priv)
                 ggtt->base.total >> 20);
        DRM_DEBUG_DRIVER("GMADR size = %lldM\n", ggtt->mappable_end >> 20);
        DRM_DEBUG_DRIVER("GTT stolen size = %uM\n", ggtt->stolen_size >> 20);
-#ifdef CONFIG_INTEL_IOMMU
-       if (intel_iommu_gfx_mapped)
+       if (intel_vtd_active())
                DRM_INFO("VT-d active for gfx access\n");
-#endif
 
        return 0;
 }
index f3abdc27c5dd16171dd0d5b00560148d30ab3aca..681db6083f4dac0a37336c9b85238c338723bb8b 100644 (file)
@@ -414,12 +414,10 @@ int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
                return 0;
        }
 
-#ifdef CONFIG_INTEL_IOMMU
-       if (intel_iommu_gfx_mapped && INTEL_GEN(dev_priv) < 8) {
+       if (intel_vtd_active() && INTEL_GEN(dev_priv) < 8) {
                DRM_INFO("DMAR active, disabling use of stolen memory\n");
                return 0;
        }
-#endif
 
        if (ggtt->stolen_size == 0)
                return 0;
index ded2add18b26122d7f6395d0d5532da26dd21f34..64e44d9fa6a53adfc8de4288e0669a6971e54343 100644 (file)
@@ -1312,14 +1312,12 @@ static int intel_sanitize_fbc_option(struct drm_i915_private *dev_priv)
 
 static bool need_fbc_vtd_wa(struct drm_i915_private *dev_priv)
 {
-#ifdef CONFIG_INTEL_IOMMU
        /* WaFbcTurnOffFbcWhenHyperVisorIsUsed:skl,bxt */
-       if (intel_iommu_gfx_mapped &&
+       if (intel_vtd_active() &&
            (IS_SKYLAKE(dev_priv) || IS_BROXTON(dev_priv))) {
                DRM_INFO("Disabling framebuffer compression (FBC) to prevent screen flicker with VT-d enabled\n");
                return true;
        }
-#endif
 
        return false;
 }