@@ -1133,7 +1133,6 @@ static struct i915_gem_engines *default_engines(struct i915_gem_context *ctx,
err = ERR_PTR(ret);
goto free_engines;
}
-
}
return e;
@@ -1265,10 +1264,15 @@ static void i915_gem_context_release_work(struct work_struct *work)
struct i915_gem_context *ctx = container_of(work, typeof(*ctx),
release_work);
struct i915_address_space *vm;
+ unsigned long flags;
trace_i915_context_free(ctx);
GEM_BUG_ON(!i915_gem_context_is_closed(ctx));
+ spin_lock_irqsave(&ctx->i915->gem.contexts.lock, flags);
+ list_del(&ctx->link);
+ spin_unlock_irqrestore(&ctx->i915->gem.contexts.lock, flags);
+
if (ctx->syncobj)
drm_syncobj_put(ctx->syncobj);
@@ -1521,10 +1525,6 @@ static void context_close(struct i915_gem_context *ctx)
ctx->file_priv = ERR_PTR(-EBADF);
- spin_lock(&ctx->i915->gem.contexts.lock);
- list_del(&ctx->link);
- spin_unlock(&ctx->i915->gem.contexts.lock);
-
client = ctx->client;
if (client) {
spin_lock(&client->ctx_lock);
@@ -1717,9 +1717,9 @@ static void gem_context_register(struct i915_gem_context *ctx,
list_add_tail_rcu(&ctx->client_link, &ctx->client->ctx_list);
spin_unlock(&ctx->client->ctx_lock);
- spin_lock(&i915->gem.contexts.lock);
+ spin_lock_irq(&i915->gem.contexts.lock);
list_add_tail(&ctx->link, &i915->gem.contexts.list);
- spin_unlock(&i915->gem.contexts.lock);
+ spin_unlock_irq(&i915->gem.contexts.lock);
}
int i915_gem_context_open(struct drm_i915_private *i915,
@@ -2377,24 +2377,26 @@ oa_configure_all_contexts(struct i915_perf_stream *stream,
* context. Contexts idle at the time of reconfiguration are not
* trapped behind the barrier.
*/
- spin_lock(&i915->gem.contexts.lock);
+ spin_lock_irq(&i915->gem.contexts.lock);
list_for_each_entry_safe(ctx, cn, &i915->gem.contexts.list, link) {
if (!kref_get_unless_zero(&ctx->ref))
continue;
- spin_unlock(&i915->gem.contexts.lock);
+ spin_unlock_irq(&i915->gem.contexts.lock);
- err = gen8_configure_context(ctx, regs, num_regs);
- if (err) {
- i915_gem_context_put(ctx);
- return err;
+ if (!i915_gem_context_is_closed(ctx)) {
+ err = gen8_configure_context(ctx, regs, num_regs);
+ if (err) {
+ i915_gem_context_put(ctx);
+ return err;
+ }
}
- spin_lock(&i915->gem.contexts.lock);
+ spin_lock_irq(&i915->gem.contexts.lock);
list_safe_reset_next(ctx, cn, link);
i915_gem_context_put(ctx);
}
- spin_unlock(&i915->gem.contexts.lock);
+ spin_unlock_irq(&i915->gem.contexts.lock);
/*
* After updating all other contexts, we need to modify ourselves.
@@ -77,12 +77,12 @@ i915_l3_read(struct file *filp, struct kobject *kobj,
count = min_t(size_t, GEN7_L3LOG_SIZE - offset, count);
memset(buf, 0, count);
- spin_lock(&i915->gem.contexts.lock);
+ spin_lock_irq(&i915->gem.contexts.lock);
if (i915->l3_parity.remap_info[slice])
memcpy(buf,
i915->l3_parity.remap_info[slice] + offset / sizeof(u32),
count);
- spin_unlock(&i915->gem.contexts.lock);
+ spin_unlock_irq(&i915->gem.contexts.lock);
return count;
}
@@ -110,7 +110,7 @@ i915_l3_write(struct file *filp, struct kobject *kobj,
if (!remap_info)
return -ENOMEM;
- spin_lock(&i915->gem.contexts.lock);
+ spin_lock_irq(&i915->gem.contexts.lock);
if (i915->l3_parity.remap_info[slice]) {
freeme = remap_info;
@@ -126,7 +126,7 @@ i915_l3_write(struct file *filp, struct kobject *kobj,
list_for_each_entry(ctx, &i915->gem.contexts.list, link)
ctx->remap_slice |= BIT(slice);
- spin_unlock(&i915->gem.contexts.lock);
+ spin_unlock_irq(&i915->gem.contexts.lock);
kfree(freeme);
/*