intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Consolidate #ifdef CONFIG_INTEL_IOMMU
@ 2017-05-25 12:16 Chris Wilson
  2017-05-25 13:03 ` ✓ Fi.CI.BAT: success for " Patchwork
  2017-05-25 13:58 ` [PATCH] " Tvrtko Ursulin
  0 siblings, 2 replies; 4+ messages in thread
From: Chris Wilson @ 2017-05-25 12:16 UTC (permalink / raw)
  To: intel-gfx

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>
---
 drivers/gpu/drm/i915/i915_drv.h        | 15 ++++++++-------
 drivers/gpu/drm/i915/i915_gem.c        |  4 +---
 drivers/gpu/drm/i915/i915_gem_gtt.c    | 14 +++-----------
 drivers/gpu/drm/i915/i915_gem_stolen.c |  4 +---
 drivers/gpu/drm/i915/intel_fbc.c       |  4 +---
 5 files changed, 14 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index a5a01b683d48..9ba22427c05c 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -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,
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index a637cc05cc4a..7ab47a84671f 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -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;
 }
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 13292eb4e827..0c1008a2bbda 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -168,13 +168,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) {
@@ -1992,14 +1990,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)
@@ -3039,10 +3033,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;
 }
diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
index f3abdc27c5dd..681db6083f4d 100644
--- a/drivers/gpu/drm/i915/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
@@ -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;
diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c
index db7f8f0a1f36..ff2fc5bc4af4 100644
--- a/drivers/gpu/drm/i915/intel_fbc.c
+++ b/drivers/gpu/drm/i915/intel_fbc.c
@@ -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;
 }
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* ✓ Fi.CI.BAT: success for drm/i915: Consolidate #ifdef CONFIG_INTEL_IOMMU
  2017-05-25 12:16 [PATCH] drm/i915: Consolidate #ifdef CONFIG_INTEL_IOMMU Chris Wilson
@ 2017-05-25 13:03 ` Patchwork
  2017-05-25 13:58 ` [PATCH] " Tvrtko Ursulin
  1 sibling, 0 replies; 4+ messages in thread
From: Patchwork @ 2017-05-25 13:03 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Consolidate #ifdef CONFIG_INTEL_IOMMU
URL   : https://patchwork.freedesktop.org/series/24913/
State : success

== Summary ==

Series 24913v1 drm/i915: Consolidate #ifdef CONFIG_INTEL_IOMMU
https://patchwork.freedesktop.org/api/1.0/series/24913/revisions/1/mbox/

Test gem_exec_flush:
        Subgroup basic-batch-kernel-default-uc:
                fail       -> PASS       (fi-snb-2600) fdo#100007
Test kms_cursor_legacy:
        Subgroup basic-busy-flip-before-cursor-atomic:
                fail       -> PASS       (fi-snb-2600) fdo#100215

fdo#100007 https://bugs.freedesktop.org/show_bug.cgi?id=100007
fdo#100215 https://bugs.freedesktop.org/show_bug.cgi?id=100215

fi-bdw-5557u     total:278  pass:267  dwarn:0   dfail:0   fail:0   skip:11  time:444s
fi-bdw-gvtdvm    total:278  pass:256  dwarn:8   dfail:0   fail:0   skip:14  time:432s
fi-bsw-n3050     total:278  pass:242  dwarn:0   dfail:0   fail:0   skip:36  time:588s
fi-bxt-j4205     total:278  pass:259  dwarn:0   dfail:0   fail:0   skip:19  time:517s
fi-byt-j1900     total:278  pass:254  dwarn:0   dfail:0   fail:0   skip:24  time:483s
fi-byt-n2820     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time:481s
fi-hsw-4770      total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time:422s
fi-hsw-4770r     total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time:417s
fi-ilk-650       total:278  pass:228  dwarn:0   dfail:0   fail:0   skip:50  time:421s
fi-ivb-3520m     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time:497s
fi-ivb-3770      total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time:470s
fi-kbl-7500u     total:278  pass:255  dwarn:5   dfail:0   fail:0   skip:18  time:462s
fi-kbl-7560u     total:278  pass:263  dwarn:5   dfail:0   fail:0   skip:10  time:576s
fi-skl-6260u     total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time:455s
fi-skl-6700hq    total:278  pass:239  dwarn:0   dfail:1   fail:17  skip:21  time:431s
fi-skl-6700k     total:278  pass:256  dwarn:4   dfail:0   fail:0   skip:18  time:462s
fi-skl-6770hq    total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time:495s
fi-skl-gvtdvm    total:278  pass:265  dwarn:0   dfail:0   fail:0   skip:13  time:435s
fi-snb-2520m     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time:534s
fi-snb-2600      total:278  pass:249  dwarn:0   dfail:0   fail:0   skip:29  time:399s

028a0b3762b318a72ab04675355db97c854c230b drm-tip: 2017y-05m-25d-11h-47m-22s UTC integration manifest
69cb4d9e drm/i915: Consolidate #ifdef CONFIG_INTEL_IOMMU

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4808/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/i915: Consolidate #ifdef CONFIG_INTEL_IOMMU
  2017-05-25 12:16 [PATCH] drm/i915: Consolidate #ifdef CONFIG_INTEL_IOMMU Chris Wilson
  2017-05-25 13:03 ` ✓ Fi.CI.BAT: success for " Patchwork
@ 2017-05-25 13:58 ` Tvrtko Ursulin
  2017-05-25 20:54   ` Chris Wilson
  1 sibling, 1 reply; 4+ messages in thread
From: Tvrtko Ursulin @ 2017-05-25 13:58 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx


On 25/05/2017 13:16, Chris Wilson wrote:
> 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>
> ---
>  drivers/gpu/drm/i915/i915_drv.h        | 15 ++++++++-------
>  drivers/gpu/drm/i915/i915_gem.c        |  4 +---
>  drivers/gpu/drm/i915/i915_gem_gtt.c    | 14 +++-----------
>  drivers/gpu/drm/i915/i915_gem_stolen.c |  4 +---
>  drivers/gpu/drm/i915/intel_fbc.c       |  4 +---
>  5 files changed, 14 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index a5a01b683d48..9ba22427c05c 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -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,
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index a637cc05cc4a..7ab47a84671f 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -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;
>  }
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 13292eb4e827..0c1008a2bbda 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -168,13 +168,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) {
> @@ -1992,14 +1990,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)
> @@ -3039,10 +3033,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;
>  }
> diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
> index f3abdc27c5dd..681db6083f4d 100644
> --- a/drivers/gpu/drm/i915/i915_gem_stolen.c
> +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
> @@ -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;
> diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c
> index db7f8f0a1f36..ff2fc5bc4af4 100644
> --- a/drivers/gpu/drm/i915/intel_fbc.c
> +++ b/drivers/gpu/drm/i915/intel_fbc.c
> @@ -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;
>  }
>

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/i915: Consolidate #ifdef CONFIG_INTEL_IOMMU
  2017-05-25 13:58 ` [PATCH] " Tvrtko Ursulin
@ 2017-05-25 20:54   ` Chris Wilson
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Wilson @ 2017-05-25 20:54 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: intel-gfx

On Thu, May 25, 2017 at 02:58:32PM +0100, Tvrtko Ursulin wrote:
> 
> On 25/05/2017 13:16, Chris Wilson wrote:
> >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>
> 
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Thanks for checking it over, pushed.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-05-25 20:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-25 12:16 [PATCH] drm/i915: Consolidate #ifdef CONFIG_INTEL_IOMMU Chris Wilson
2017-05-25 13:03 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-05-25 13:58 ` [PATCH] " Tvrtko Ursulin
2017-05-25 20:54   ` Chris Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).