mirror of
https://github.com/torvalds/linux.git
synced 2026-04-20 15:53:59 -04:00
drm/i915: Move context management under GEM
Keep track of the GEM contexts underneath i915->gem.contexts and assign them their own lock for the purposes of list management. v2: Focus on lock tracking; ctx->vm is protected by ctx->mutex v3: Correct split with removal of logical HW ID Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20191004134015.13204-15-chris@chris-wilson.co.uk
This commit is contained in:
@@ -316,12 +316,18 @@ static void print_context_stats(struct seq_file *m,
|
||||
struct drm_i915_private *i915)
|
||||
{
|
||||
struct file_stats kstats = {};
|
||||
struct i915_gem_context *ctx;
|
||||
struct i915_gem_context *ctx, *cn;
|
||||
|
||||
list_for_each_entry(ctx, &i915->contexts.list, link) {
|
||||
spin_lock(&i915->gem.contexts.lock);
|
||||
list_for_each_entry_safe(ctx, cn, &i915->gem.contexts.list, link) {
|
||||
struct i915_gem_engines_iter it;
|
||||
struct intel_context *ce;
|
||||
|
||||
if (!kref_get_unless_zero(&ctx->ref))
|
||||
continue;
|
||||
|
||||
spin_unlock(&i915->gem.contexts.lock);
|
||||
|
||||
for_each_gem_engine(ce,
|
||||
i915_gem_context_lock_engines(ctx), it) {
|
||||
intel_context_lock_pinned(ce);
|
||||
@@ -338,7 +344,9 @@ static void print_context_stats(struct seq_file *m,
|
||||
i915_gem_context_unlock_engines(ctx);
|
||||
|
||||
if (!IS_ERR_OR_NULL(ctx->file_priv)) {
|
||||
struct file_stats stats = { .vm = ctx->vm, };
|
||||
struct file_stats stats = {
|
||||
.vm = rcu_access_pointer(ctx->vm),
|
||||
};
|
||||
struct drm_file *file = ctx->file_priv->file;
|
||||
struct task_struct *task;
|
||||
char name[80];
|
||||
@@ -355,7 +363,12 @@ static void print_context_stats(struct seq_file *m,
|
||||
|
||||
print_file_stats(m, name, stats);
|
||||
}
|
||||
|
||||
spin_lock(&i915->gem.contexts.lock);
|
||||
list_safe_reset_next(ctx, cn, link);
|
||||
i915_gem_context_put(ctx);
|
||||
}
|
||||
spin_unlock(&i915->gem.contexts.lock);
|
||||
|
||||
print_file_stats(m, "[k]contexts", kstats);
|
||||
}
|
||||
@@ -363,7 +376,6 @@ static void print_context_stats(struct seq_file *m,
|
||||
static int i915_gem_object_info(struct seq_file *m, void *data)
|
||||
{
|
||||
struct drm_i915_private *i915 = node_to_i915(m->private);
|
||||
int ret;
|
||||
|
||||
seq_printf(m, "%u shrinkable [%u free] objects, %llu bytes\n",
|
||||
i915->mm.shrink_count,
|
||||
@@ -372,12 +384,7 @@ static int i915_gem_object_info(struct seq_file *m, void *data)
|
||||
|
||||
seq_putc(m, '\n');
|
||||
|
||||
ret = mutex_lock_interruptible(&i915->drm.struct_mutex);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
print_context_stats(m, i915);
|
||||
mutex_unlock(&i915->drm.struct_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1579,19 +1586,19 @@ static void describe_ctx_ring(struct seq_file *m, struct intel_ring *ring)
|
||||
|
||||
static int i915_context_status(struct seq_file *m, void *unused)
|
||||
{
|
||||
struct drm_i915_private *dev_priv = node_to_i915(m->private);
|
||||
struct drm_device *dev = &dev_priv->drm;
|
||||
struct i915_gem_context *ctx;
|
||||
int ret;
|
||||
struct drm_i915_private *i915 = node_to_i915(m->private);
|
||||
struct i915_gem_context *ctx, *cn;
|
||||
|
||||
ret = mutex_lock_interruptible(&dev->struct_mutex);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
list_for_each_entry(ctx, &dev_priv->contexts.list, link) {
|
||||
spin_lock(&i915->gem.contexts.lock);
|
||||
list_for_each_entry_safe(ctx, cn, &i915->gem.contexts.list, link) {
|
||||
struct i915_gem_engines_iter it;
|
||||
struct intel_context *ce;
|
||||
|
||||
if (!kref_get_unless_zero(&ctx->ref))
|
||||
continue;
|
||||
|
||||
spin_unlock(&i915->gem.contexts.lock);
|
||||
|
||||
seq_puts(m, "HW context ");
|
||||
if (ctx->pid) {
|
||||
struct task_struct *task;
|
||||
@@ -1626,9 +1633,12 @@ static int i915_context_status(struct seq_file *m, void *unused)
|
||||
i915_gem_context_unlock_engines(ctx);
|
||||
|
||||
seq_putc(m, '\n');
|
||||
}
|
||||
|
||||
mutex_unlock(&dev->struct_mutex);
|
||||
spin_lock(&i915->gem.contexts.lock);
|
||||
list_safe_reset_next(ctx, cn, link);
|
||||
i915_gem_context_put(ctx);
|
||||
}
|
||||
spin_unlock(&i915->gem.contexts.lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user