[Intel-gfx] [PATCH 2/2] drm/i915: Sanitize hardware context computation

Joonas Lahtinen joonas.lahtinen at linux.intel.com
Wed Apr 26 09:11:54 UTC 2017


Inspired by the engine context size sanitization, lets also clean the
legacy hardware context computation.

Signed-off-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem_context.c | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 8bd0c49..d82135d 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -94,29 +94,23 @@
 
 static int get_context_size(struct drm_i915_private *dev_priv)
 {
-	int ret;
 	u32 reg;
 
 	switch (INTEL_GEN(dev_priv)) {
-	case 6:
-		reg = I915_READ(CXT_SIZE);
-		ret = GEN6_CXT_TOTAL_SIZE(reg) * 64;
-		break;
+	default:
+		MISSING_CASE(INTEL_GEN(dev_priv));
+	case 8:
+		return GEN8_CXT_TOTAL_SIZE;
 	case 7:
-		reg = I915_READ(GEN7_CXT_SIZE);
 		if (IS_HASWELL(dev_priv))
-			ret = HSW_CXT_TOTAL_SIZE;
-		else
-			ret = GEN7_CXT_TOTAL_SIZE(reg) * 64;
-		break;
-	case 8:
-		ret = GEN8_CXT_TOTAL_SIZE;
-		break;
-	default:
-		BUG();
-	}
+			return HSW_CXT_TOTAL_SIZE;
 
-	return ret;
+		reg = I915_READ(GEN7_CXT_SIZE);
+		return GEN7_CXT_TOTAL_SIZE(reg) * 64;
+	case 6:
+		reg = I915_READ(CXT_SIZE);
+		return GEN6_CXT_TOTAL_SIZE(reg) * 64;
+	}
 }
 
 void i915_gem_context_free(struct kref *ctx_ref)
-- 
2.7.4



More information about the Intel-gfx mailing list