drm/i915/guc: Assert that we switch between known ggtt->invalidate functions
authorChris Wilson <[email protected]>
Thu, 1 Jun 2017 09:04:46 +0000 (10:04 +0100)
committerChris Wilson <[email protected]>
Thu, 1 Jun 2017 13:17:41 +0000 (14:17 +0100)
When we enable the GuC, we enable an alternative mechanism for doing
post-GGTT update invalidation. Likewise, when we disable the GuC, we
restore the previous method. Assert that we change between known
endpoints, so that we can catch if we accidentally clobber some other
gen and if we change the invalidate routine without updating guc.

Signed-off-by: Chris Wilson <[email protected]>
Cc: Tvrtko Ursulin <[email protected]>
Cc: Joonas Lahtinen <[email protected]>
Cc: Oscar Mateo <[email protected]>
Cc: Daniele Ceraolo Spurio <[email protected]>
Cc: Michal Wajdeczko <[email protected]>
Cc: Arkadiusz Hiler <[email protected]>
Cc: Michel Thierry <[email protected]>
Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
Reviewed-by: Michal Wajdeczko <[email protected]>
Reviewed-by: Joonas Lahtinen <[email protected]>
drivers/gpu/drm/i915/i915_gem_gtt.c

index 1489c3af714599cbf0bece316ef784fbfd4d834e..4ff854e6413cf84f64ba4bed6abea83c085a6a01 100644 (file)
@@ -3095,13 +3095,17 @@ int i915_ggtt_enable_hw(struct drm_i915_private *dev_priv)
 
 void i915_ggtt_enable_guc(struct drm_i915_private *i915)
 {
+       GEM_BUG_ON(i915->ggtt.invalidate != gen6_ggtt_invalidate);
+
        i915->ggtt.invalidate = guc_ggtt_invalidate;
 }
 
 void i915_ggtt_disable_guc(struct drm_i915_private *i915)
 {
-       if (i915->ggtt.invalidate == guc_ggtt_invalidate)
-               i915->ggtt.invalidate = gen6_ggtt_invalidate;
+       /* We should only be called after i915_ggtt_enable_guc() */
+       GEM_BUG_ON(i915->ggtt.invalidate != guc_ggtt_invalidate);
+
+       i915->ggtt.invalidate = gen6_ggtt_invalidate;
 }
 
 void i915_gem_restore_gtt_mappings(struct drm_i915_private *dev_priv)