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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx>
Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
---
 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

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




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux