[Intel-gfx] [PATCH 03/50] drm/i915: Simplify a couple of functions thanks to for_each_ring

oscar.mateo at intel.com oscar.mateo at intel.com
Fri May 9 14:08:33 CEST 2014


From: Oscar Mateo <oscar.mateo at intel.com>

This patch should have no functional changes.

Signed-off-by: Oscar Mateo <oscar.mateo at intel.com>
---
 drivers/gpu/drm/i915/i915_gem_context.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 948df20..014fb8f 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -359,12 +359,12 @@ err_destroy:
 void i915_gem_context_reset(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_ring_buffer *ring;
 	int i;
 
 	/* Prevent the hardware from restoring the last context (which hung) on
 	 * the next switch */
-	for (i = 0; i < I915_NUM_RINGS; i++) {
-		struct intel_ring_buffer *ring = &dev_priv->ring[i];
+	for_each_ring(ring, dev_priv, i) {
 		struct i915_hw_context *dctx = ring->default_context;
 
 		/* Do a fake switch to the default context */
@@ -392,7 +392,8 @@ int i915_gem_context_init(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct i915_hw_context *ctx;
-	int i;
+	struct intel_ring_buffer *ring;
+	int unused;
 
 	/* Init should only be called once per module load. Eventually the
 	 * restriction on the context_disabled check can be loosened. */
@@ -416,8 +417,8 @@ int i915_gem_context_init(struct drm_device *dev)
 	}
 
 	/* NB: RCS will hold a ref for all rings */
-	for (i = 0; i < I915_NUM_RINGS; i++)
-		dev_priv->ring[i].default_context = ctx;
+	for_each_ring(ring, dev_priv, unused)
+		ring->default_context = ctx;
 
 	DRM_DEBUG_DRIVER("%s context support initialized\n", dev_priv->hw_context_size ? "HW" : "fake");
 	return 0;
@@ -427,7 +428,8 @@ void i915_gem_context_fini(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct i915_hw_context *dctx = dev_priv->ring[RCS].default_context;
-	int i;
+	struct intel_ring_buffer *ring;
+	int unused;
 
 	if (dctx->obj) {
 		/* The only known way to stop the gpu from accessing the hw context is
@@ -451,9 +453,7 @@ void i915_gem_context_fini(struct drm_device *dev)
 		}
 	}
 
-	for (i = 0; i < I915_NUM_RINGS; i++) {
-		struct intel_ring_buffer *ring = &dev_priv->ring[i];
-
+	for_each_ring(ring, dev_priv, unused) {
 		if (ring->last_context)
 			i915_gem_context_unreference(ring->last_context);
 
-- 
1.9.0




More information about the Intel-gfx mailing list