@@ -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);