Commit a33afea5 authored by Ben Widawsky's avatar Ben Widawsky Committed by Daniel Vetter

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: default avatarBen Widawsky <ben@bwidawsk.net>
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent c3787e2e
...@@ -1442,6 +1442,7 @@ static int i915_context_status(struct seq_file *m, void *unused) ...@@ -1442,6 +1442,7 @@ static int i915_context_status(struct seq_file *m, void *unused)
struct drm_device *dev = node->minor->dev; struct drm_device *dev = node->minor->dev;
drm_i915_private_t *dev_priv = dev->dev_private; drm_i915_private_t *dev_priv = dev->dev_private;
struct intel_ring_buffer *ring; struct intel_ring_buffer *ring;
struct i915_hw_context *ctx;
int ret, i; int ret, i;
ret = mutex_lock_interruptible(&dev->mode_config.mutex); ret = mutex_lock_interruptible(&dev->mode_config.mutex);
...@@ -1460,12 +1461,14 @@ static int i915_context_status(struct seq_file *m, void *unused) ...@@ -1460,12 +1461,14 @@ static int i915_context_status(struct seq_file *m, void *unused)
seq_putc(m, '\n'); seq_putc(m, '\n');
} }
for_each_ring(ring, dev_priv, i) { list_for_each_entry(ctx, &dev_priv->context_list, link) {
if (ring->default_context) { seq_puts(m, "HW context ");
seq_printf(m, "HW default context %s ", ring->name); for_each_ring(ring, dev_priv, i)
describe_obj(m, ring->default_context->obj); if (ring->default_context == ctx)
seq_putc(m, '\n'); seq_printf(m, "(default context %s) ", ring->name);
}
describe_obj(m, ctx->obj);
seq_putc(m, '\n');
} }
mutex_unlock(&dev->mode_config.mutex); mutex_unlock(&dev->mode_config.mutex);
......
...@@ -605,6 +605,8 @@ struct i915_hw_context { ...@@ -605,6 +605,8 @@ struct i915_hw_context {
struct intel_ring_buffer *ring; struct intel_ring_buffer *ring;
struct drm_i915_gem_object *obj; struct drm_i915_gem_object *obj;
struct i915_ctx_hang_stats hang_stats; struct i915_ctx_hang_stats hang_stats;
struct list_head link;
}; };
struct i915_fbc { struct i915_fbc {
...@@ -1343,6 +1345,7 @@ typedef struct drm_i915_private { ...@@ -1343,6 +1345,7 @@ typedef struct drm_i915_private {
bool hw_contexts_disabled; bool hw_contexts_disabled;
uint32_t hw_context_size; uint32_t hw_context_size;
struct list_head context_list;
u32 fdi_rx_config; u32 fdi_rx_config;
......
...@@ -4541,6 +4541,7 @@ i915_gem_load(struct drm_device *dev) ...@@ -4541,6 +4541,7 @@ i915_gem_load(struct drm_device *dev)
INIT_LIST_HEAD(&dev_priv->vm_list); INIT_LIST_HEAD(&dev_priv->vm_list);
i915_init_vm(dev_priv, &dev_priv->gtt.base); i915_init_vm(dev_priv, &dev_priv->gtt.base);
INIT_LIST_HEAD(&dev_priv->context_list);
INIT_LIST_HEAD(&dev_priv->mm.unbound_list); INIT_LIST_HEAD(&dev_priv->mm.unbound_list);
INIT_LIST_HEAD(&dev_priv->mm.bound_list); INIT_LIST_HEAD(&dev_priv->mm.bound_list);
INIT_LIST_HEAD(&dev_priv->mm.fence_list); INIT_LIST_HEAD(&dev_priv->mm.fence_list);
......
...@@ -129,6 +129,7 @@ void i915_gem_context_free(struct kref *ctx_ref) ...@@ -129,6 +129,7 @@ void i915_gem_context_free(struct kref *ctx_ref)
struct i915_hw_context *ctx = container_of(ctx_ref, struct i915_hw_context *ctx = container_of(ctx_ref,
typeof(*ctx), ref); typeof(*ctx), ref);
list_del(&ctx->link);
drm_gem_object_unreference(&ctx->obj->base); drm_gem_object_unreference(&ctx->obj->base);
kfree(ctx); kfree(ctx);
} }
...@@ -147,6 +148,7 @@ create_hw_context(struct drm_device *dev, ...@@ -147,6 +148,7 @@ create_hw_context(struct drm_device *dev,
kref_init(&ctx->ref); kref_init(&ctx->ref);
ctx->obj = i915_gem_alloc_object(dev, dev_priv->hw_context_size); ctx->obj = i915_gem_alloc_object(dev, dev_priv->hw_context_size);
INIT_LIST_HEAD(&ctx->link);
if (ctx->obj == NULL) { if (ctx->obj == NULL) {
kfree(ctx); kfree(ctx);
DRM_DEBUG_DRIVER("Context object allocated failed\n"); DRM_DEBUG_DRIVER("Context object allocated failed\n");
...@@ -166,6 +168,7 @@ create_hw_context(struct drm_device *dev, ...@@ -166,6 +168,7 @@ create_hw_context(struct drm_device *dev,
* assertion in the context switch code. * assertion in the context switch code.
*/ */
ctx->ring = &dev_priv->ring[RCS]; ctx->ring = &dev_priv->ring[RCS];
list_add_tail(&ctx->link, &dev_priv->context_list);
/* Default context will never have a file_priv */ /* Default context will never have a file_priv */
if (file_priv == NULL) if (file_priv == NULL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment