Commit 80debff8 authored by Chris Wilson's avatar Chris Wilson

drm/i915: Consolidate #ifdef CONFIG_INTEL_IOMMU

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: default avatarChris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/20170525121612.2190-1-chris@chris-wilson.co.ukReviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
parent b2241f18
...@@ -2997,23 +2997,24 @@ intel_info(const struct drm_i915_private *dev_priv) ...@@ -2997,23 +2997,24 @@ intel_info(const struct drm_i915_private *dev_priv)
#include "i915_trace.h" #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 #ifdef CONFIG_INTEL_IOMMU
if (INTEL_GEN(dev_priv) >= 6 && intel_iommu_gfx_mapped) if (intel_iommu_gfx_mapped)
return true; return true;
#endif #endif
return false; 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 static inline bool
intel_ggtt_update_needs_vtd_wa(struct drm_i915_private *dev_priv) intel_ggtt_update_needs_vtd_wa(struct drm_i915_private *dev_priv)
{ {
#ifdef CONFIG_INTEL_IOMMU return IS_BROXTON(dev_priv) && intel_vtd_active();
if (IS_BROXTON(dev_priv) && intel_iommu_gfx_mapped)
return true;
#endif
return false;
} }
int intel_sanitize_enable_ppgtt(struct drm_i915_private *dev_priv, int intel_sanitize_enable_ppgtt(struct drm_i915_private *dev_priv,
......
...@@ -4728,11 +4728,9 @@ bool intel_sanitize_semaphores(struct drm_i915_private *dev_priv, int value) ...@@ -4728,11 +4728,9 @@ bool intel_sanitize_semaphores(struct drm_i915_private *dev_priv, int value)
if (value >= 0) if (value >= 0)
return value; return value;
#ifdef CONFIG_INTEL_IOMMU
/* Enable semaphores on SNB when IO remapping is off */ /* 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; return false;
#endif
return true; return true;
} }
......
...@@ -166,13 +166,11 @@ int intel_sanitize_enable_ppgtt(struct drm_i915_private *dev_priv, ...@@ -166,13 +166,11 @@ int intel_sanitize_enable_ppgtt(struct drm_i915_private *dev_priv,
if (enable_ppgtt == 3 && has_full_48bit_ppgtt) if (enable_ppgtt == 3 && has_full_48bit_ppgtt)
return 3; return 3;
#ifdef CONFIG_INTEL_IOMMU
/* Disable ppgtt on SNB if VT-d is on. */ /* 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"); DRM_INFO("Disabling PPGTT because VT-d is on\n");
return 0; return 0;
} }
#endif
/* Early VLV doesn't have this */ /* Early VLV doesn't have this */
if (IS_VALLEYVIEW(dev_priv) && dev_priv->drm.pdev->revision < 0xb) { if (IS_VALLEYVIEW(dev_priv) && dev_priv->drm.pdev->revision < 0xb) {
...@@ -1990,14 +1988,10 @@ void i915_ppgtt_release(struct kref *kref) ...@@ -1990,14 +1988,10 @@ void i915_ppgtt_release(struct kref *kref)
*/ */
static bool needs_idle_maps(struct drm_i915_private *dev_priv) 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 /* Query intel_iommu to see if we need the workaround. Presumably that
* was loaded first. * was loaded first.
*/ */
if (IS_GEN5(dev_priv) && IS_MOBILE(dev_priv) && intel_iommu_gfx_mapped) return IS_GEN5(dev_priv) && IS_MOBILE(dev_priv) && intel_vtd_active();
return true;
#endif
return false;
} }
void i915_check_and_clear_faults(struct drm_i915_private *dev_priv) 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) ...@@ -3037,10 +3031,8 @@ int i915_ggtt_probe_hw(struct drm_i915_private *dev_priv)
ggtt->base.total >> 20); ggtt->base.total >> 20);
DRM_DEBUG_DRIVER("GMADR size = %lldM\n", ggtt->mappable_end >> 20); DRM_DEBUG_DRIVER("GMADR size = %lldM\n", ggtt->mappable_end >> 20);
DRM_DEBUG_DRIVER("GTT stolen size = %uM\n", ggtt->stolen_size >> 20); DRM_DEBUG_DRIVER("GTT stolen size = %uM\n", ggtt->stolen_size >> 20);
#ifdef CONFIG_INTEL_IOMMU if (intel_vtd_active())
if (intel_iommu_gfx_mapped)
DRM_INFO("VT-d active for gfx access\n"); DRM_INFO("VT-d active for gfx access\n");
#endif
return 0; return 0;
} }
......
...@@ -414,12 +414,10 @@ int i915_gem_init_stolen(struct drm_i915_private *dev_priv) ...@@ -414,12 +414,10 @@ int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
return 0; return 0;
} }
#ifdef CONFIG_INTEL_IOMMU if (intel_vtd_active() && INTEL_GEN(dev_priv) < 8) {
if (intel_iommu_gfx_mapped && INTEL_GEN(dev_priv) < 8) {
DRM_INFO("DMAR active, disabling use of stolen memory\n"); DRM_INFO("DMAR active, disabling use of stolen memory\n");
return 0; return 0;
} }
#endif
if (ggtt->stolen_size == 0) if (ggtt->stolen_size == 0)
return 0; return 0;
......
...@@ -1312,14 +1312,12 @@ static int intel_sanitize_fbc_option(struct drm_i915_private *dev_priv) ...@@ -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) static bool need_fbc_vtd_wa(struct drm_i915_private *dev_priv)
{ {
#ifdef CONFIG_INTEL_IOMMU
/* WaFbcTurnOffFbcWhenHyperVisorIsUsed:skl,bxt */ /* WaFbcTurnOffFbcWhenHyperVisorIsUsed:skl,bxt */
if (intel_iommu_gfx_mapped && if (intel_vtd_active() &&
(IS_SKYLAKE(dev_priv) || IS_BROXTON(dev_priv))) { (IS_SKYLAKE(dev_priv) || IS_BROXTON(dev_priv))) {
DRM_INFO("Disabling framebuffer compression (FBC) to prevent screen flicker with VT-d enabled\n"); DRM_INFO("Disabling framebuffer compression (FBC) to prevent screen flicker with VT-d enabled\n");
return true; return true;
} }
#endif
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment