[Intel-gfx] [PATCH 04/49] drm/i915: Simplify a couple of functions thanks to for_each_ring
oscar.mateo at intel.com
oscar.mateo at intel.com
Thu Mar 27 18:59:33 CET 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 | 37 +++++++++++----------------------
1 file changed, 12 insertions(+), 25 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 3cfdfbe..e1c544e 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -360,13 +360,10 @@ void i915_gem_context_reset(struct drm_device *dev)
/* Prevent the hardware from restoring the last context (which hung) on
* the next switch */
- for (i = 0; i < I915_NUM_RINGS; i++) {
+ for_each_ring(ring, dev_priv, i) {
struct i915_hw_context *dctx;
- if (!(INTEL_INFO(dev)->ring_mask & (1<<i)))
- continue;
/* Do a fake switch to the default context */
- ring = &dev_priv->ring[i];
dctx = ring->default_context;
if (WARN_ON(!dctx))
continue;
@@ -395,7 +392,8 @@ int i915_gem_context_init(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_ring_buffer *ring;
- int i;
+ struct i915_hw_context *default_context;
+ int unused;
if (!HAS_HW_CONTEXTS(dev))
return 0;
@@ -412,23 +410,15 @@ int i915_gem_context_init(struct drm_device *dev)
return -E2BIG;
}
- dev_priv->ring[RCS].default_context =
- i915_gem_create_context(dev, NULL, USES_PPGTT(dev));
-
- if (IS_ERR_OR_NULL(dev_priv->ring[RCS].default_context)) {
+ default_context = i915_gem_create_context(dev, NULL, USES_PPGTT(dev));
+ if (IS_ERR_OR_NULL(default_context)) {
DRM_DEBUG_DRIVER("Disabling HW Contexts; create failed %ld\n",
- PTR_ERR(dev_priv->ring[RCS].default_context));
- return PTR_ERR(dev_priv->ring[RCS].default_context);
+ PTR_ERR(default_context));
+ return PTR_ERR(default_context);
}
- for (i = RCS + 1; i < I915_NUM_RINGS; i++) {
- if (!(INTEL_INFO(dev)->ring_mask & (1<<i)))
- continue;
-
- ring = &dev_priv->ring[i];
-
- /* NB: RCS will hold a ref for all rings */
- ring->default_context = dev_priv->ring[RCS].default_context;
+ for_each_ring(ring, dev_priv, unused) {
+ ring->default_context = default_context;
}
DRM_DEBUG_DRIVER("HW context support initialized\n");
@@ -439,7 +429,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 (!HAS_HW_CONTEXTS(dev))
return;
@@ -464,11 +455,7 @@ void i915_gem_context_fini(struct drm_device *dev)
dev_priv->ring[RCS].last_context = NULL;
}
- for (i = 0; i < I915_NUM_RINGS; i++) {
- struct intel_ring_buffer *ring = &dev_priv->ring[i];
- if (!(INTEL_INFO(dev)->ring_mask & (1<<i)))
- continue;
-
+ 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