mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-05 18:14:07 +08:00
drm/i915/gem: Reduce ctx->engines_mutex for get_engines()
Take a snapshot of the ctx->engines, so we can avoid taking the ctx->engines_mutex for a mere read in get_engines(). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Andi Shyti <andi.shyti@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20210114135612.13210-4-chris@chris-wilson.co.uk
This commit is contained in:
parent
1a72e7414d
commit
2d60d3e0a2
@ -1843,27 +1843,6 @@ replace:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct i915_gem_engines *
|
||||
__copy_engines(struct i915_gem_engines *e)
|
||||
{
|
||||
struct i915_gem_engines *copy;
|
||||
unsigned int n;
|
||||
|
||||
copy = alloc_engines(e->num_engines);
|
||||
if (!copy)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
for (n = 0; n < e->num_engines; n++) {
|
||||
if (e->engines[n])
|
||||
copy->engines[n] = intel_context_get(e->engines[n]);
|
||||
else
|
||||
copy->engines[n] = NULL;
|
||||
}
|
||||
copy->num_engines = n;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
static int
|
||||
get_engines(struct i915_gem_context *ctx,
|
||||
struct drm_i915_gem_context_param *args)
|
||||
@ -1871,19 +1850,17 @@ get_engines(struct i915_gem_context *ctx,
|
||||
struct i915_context_param_engines __user *user;
|
||||
struct i915_gem_engines *e;
|
||||
size_t n, count, size;
|
||||
bool user_engines;
|
||||
int err = 0;
|
||||
|
||||
err = mutex_lock_interruptible(&ctx->engines_mutex);
|
||||
if (err)
|
||||
return err;
|
||||
e = __context_engines_await(ctx, &user_engines);
|
||||
if (!e)
|
||||
return -ENOENT;
|
||||
|
||||
e = NULL;
|
||||
if (i915_gem_context_user_engines(ctx))
|
||||
e = __copy_engines(i915_gem_context_engines(ctx));
|
||||
mutex_unlock(&ctx->engines_mutex);
|
||||
if (IS_ERR_OR_NULL(e)) {
|
||||
if (!user_engines) {
|
||||
i915_sw_fence_complete(&e->fence);
|
||||
args->size = 0;
|
||||
return PTR_ERR_OR_ZERO(e);
|
||||
return 0;
|
||||
}
|
||||
|
||||
count = e->num_engines;
|
||||
@ -1934,7 +1911,7 @@ get_engines(struct i915_gem_context *ctx,
|
||||
args->size = size;
|
||||
|
||||
err_free:
|
||||
free_engines(e);
|
||||
i915_sw_fence_complete(&e->fence);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user