diff options
author | Ben Widawsky <benjamin.widawsky@intel.com> | 2013-09-18 00:12:45 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-09-19 14:39:43 -0400 |
commit | a33afea5ff6e5b87ac11c87fb60b3704b3ac0fcc (patch) | |
tree | e8c6bae280dfa96ed2b0de85196b39717b3da0ca | |
parent | c3787e2eac816a597a7f92daa5d0629a85e77d56 (diff) |
drm/i915: Keep a list of all contexts
I have implemented this patch before without creating a separate list
(I'm having trouble finding the links, but the messages ids are:
<1364942743-6041-2-git-send-email-ben@bwidawsk.net>
<1365118914-15753-9-git-send-email-ben@bwidawsk.net>)
However, the code is much simpler to just use a list and it makes the
code from the next patch a lot more pretty.
As you'll see in the next patch, the reason for this is to be able to
specify when a context needs to get L3 remapping. More details there.
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r-- | drivers/gpu/drm/i915/i915_debugfs.c | 15 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_context.c | 3 |
4 files changed, 16 insertions, 6 deletions
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 1d776243bf55..ada095023dad 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c | |||
@@ -1442,6 +1442,7 @@ static int i915_context_status(struct seq_file *m, void *unused) | |||
1442 | struct drm_device *dev = node->minor->dev; | 1442 | struct drm_device *dev = node->minor->dev; |
1443 | drm_i915_private_t *dev_priv = dev->dev_private; | 1443 | drm_i915_private_t *dev_priv = dev->dev_private; |
1444 | struct intel_ring_buffer *ring; | 1444 | struct intel_ring_buffer *ring; |
1445 | struct i915_hw_context *ctx; | ||
1445 | int ret, i; | 1446 | int ret, i; |
1446 | 1447 | ||
1447 | ret = mutex_lock_interruptible(&dev->mode_config.mutex); | 1448 | ret = mutex_lock_interruptible(&dev->mode_config.mutex); |
@@ -1460,12 +1461,14 @@ static int i915_context_status(struct seq_file *m, void *unused) | |||
1460 | seq_putc(m, '\n'); | 1461 | seq_putc(m, '\n'); |
1461 | } | 1462 | } |
1462 | 1463 | ||
1463 | for_each_ring(ring, dev_priv, i) { | 1464 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
1464 | if (ring->default_context) { | 1465 | seq_puts(m, "HW context "); |
1465 | seq_printf(m, "HW default context %s ", ring->name); | 1466 | for_each_ring(ring, dev_priv, i) |
1466 | describe_obj(m, ring->default_context->obj); | 1467 | if (ring->default_context == ctx) |
1467 | seq_putc(m, '\n'); | 1468 | seq_printf(m, "(default context %s) ", ring->name); |
1468 | } | 1469 | |
1470 | describe_obj(m, ctx->obj); | ||
1471 | seq_putc(m, '\n'); | ||
1469 | } | 1472 | } |
1470 | 1473 | ||
1471 | mutex_unlock(&dev->mode_config.mutex); | 1474 | mutex_unlock(&dev->mode_config.mutex); |
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 0c39805b881e..179592762537 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -605,6 +605,8 @@ struct i915_hw_context { | |||
605 | struct intel_ring_buffer *ring; | 605 | struct intel_ring_buffer *ring; |
606 | struct drm_i915_gem_object *obj; | 606 | struct drm_i915_gem_object *obj; |
607 | struct i915_ctx_hang_stats hang_stats; | 607 | struct i915_ctx_hang_stats hang_stats; |
608 | |||
609 | struct list_head link; | ||
608 | }; | 610 | }; |
609 | 611 | ||
610 | struct i915_fbc { | 612 | struct i915_fbc { |
@@ -1343,6 +1345,7 @@ typedef struct drm_i915_private { | |||
1343 | 1345 | ||
1344 | bool hw_contexts_disabled; | 1346 | bool hw_contexts_disabled; |
1345 | uint32_t hw_context_size; | 1347 | uint32_t hw_context_size; |
1348 | struct list_head context_list; | ||
1346 | 1349 | ||
1347 | u32 fdi_rx_config; | 1350 | u32 fdi_rx_config; |
1348 | 1351 | ||
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index e4f17e594703..83464aae909f 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -4541,6 +4541,7 @@ i915_gem_load(struct drm_device *dev) | |||
4541 | INIT_LIST_HEAD(&dev_priv->vm_list); | 4541 | INIT_LIST_HEAD(&dev_priv->vm_list); |
4542 | i915_init_vm(dev_priv, &dev_priv->gtt.base); | 4542 | i915_init_vm(dev_priv, &dev_priv->gtt.base); |
4543 | 4543 | ||
4544 | INIT_LIST_HEAD(&dev_priv->context_list); | ||
4544 | INIT_LIST_HEAD(&dev_priv->mm.unbound_list); | 4545 | INIT_LIST_HEAD(&dev_priv->mm.unbound_list); |
4545 | INIT_LIST_HEAD(&dev_priv->mm.bound_list); | 4546 | INIT_LIST_HEAD(&dev_priv->mm.bound_list); |
4546 | INIT_LIST_HEAD(&dev_priv->mm.fence_list); | 4547 | INIT_LIST_HEAD(&dev_priv->mm.fence_list); |
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 26c3fccc9599..2bbdce821ac3 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c | |||
@@ -129,6 +129,7 @@ void i915_gem_context_free(struct kref *ctx_ref) | |||
129 | struct i915_hw_context *ctx = container_of(ctx_ref, | 129 | struct i915_hw_context *ctx = container_of(ctx_ref, |
130 | typeof(*ctx), ref); | 130 | typeof(*ctx), ref); |
131 | 131 | ||
132 | list_del(&ctx->link); | ||
132 | drm_gem_object_unreference(&ctx->obj->base); | 133 | drm_gem_object_unreference(&ctx->obj->base); |
133 | kfree(ctx); | 134 | kfree(ctx); |
134 | } | 135 | } |
@@ -147,6 +148,7 @@ create_hw_context(struct drm_device *dev, | |||
147 | 148 | ||
148 | kref_init(&ctx->ref); | 149 | kref_init(&ctx->ref); |
149 | ctx->obj = i915_gem_alloc_object(dev, dev_priv->hw_context_size); | 150 | ctx->obj = i915_gem_alloc_object(dev, dev_priv->hw_context_size); |
151 | INIT_LIST_HEAD(&ctx->link); | ||
150 | if (ctx->obj == NULL) { | 152 | if (ctx->obj == NULL) { |
151 | kfree(ctx); | 153 | kfree(ctx); |
152 | DRM_DEBUG_DRIVER("Context object allocated failed\n"); | 154 | DRM_DEBUG_DRIVER("Context object allocated failed\n"); |
@@ -166,6 +168,7 @@ create_hw_context(struct drm_device *dev, | |||
166 | * assertion in the context switch code. | 168 | * assertion in the context switch code. |
167 | */ | 169 | */ |
168 | ctx->ring = &dev_priv->ring[RCS]; | 170 | ctx->ring = &dev_priv->ring[RCS]; |
171 | list_add_tail(&ctx->link, &dev_priv->context_list); | ||
169 | 172 | ||
170 | /* Default context will never have a file_priv */ | 173 | /* Default context will never have a file_priv */ |
171 | if (file_priv == NULL) | 174 | if (file_priv == NULL) |