mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-24 17:23:25 -05:00
drm/i915/gem: Add a separate validate_priority helper
With the proto-context stuff added later in this series, we end up having to duplicate set_priority. This lets us avoid duplicating the validation logic. Signed-off-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20210708154835.528166-15-jason@jlekstrand.net
This commit is contained in:
parent
a4839cb113
commit
aaa5957c97
1 changed files with 27 additions and 15 deletions
|
@ -169,6 +169,28 @@ lookup_user_engine(struct i915_gem_context *ctx,
|
|||
return i915_gem_context_get_engine(ctx, idx);
|
||||
}
|
||||
|
||||
static int validate_priority(struct drm_i915_private *i915,
|
||||
const struct drm_i915_gem_context_param *args)
|
||||
{
|
||||
s64 priority = args->value;
|
||||
|
||||
if (args->size)
|
||||
return -EINVAL;
|
||||
|
||||
if (!(i915->caps.scheduler & I915_SCHEDULER_CAP_PRIORITY))
|
||||
return -ENODEV;
|
||||
|
||||
if (priority > I915_CONTEXT_MAX_USER_PRIORITY ||
|
||||
priority < I915_CONTEXT_MIN_USER_PRIORITY)
|
||||
return -EINVAL;
|
||||
|
||||
if (priority > I915_CONTEXT_DEFAULT_PRIORITY &&
|
||||
!capable(CAP_SYS_NICE))
|
||||
return -EPERM;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct i915_address_space *
|
||||
context_get_vm_rcu(struct i915_gem_context *ctx)
|
||||
{
|
||||
|
@ -1744,23 +1766,13 @@ static void __apply_priority(struct intel_context *ce, void *arg)
|
|||
static int set_priority(struct i915_gem_context *ctx,
|
||||
const struct drm_i915_gem_context_param *args)
|
||||
{
|
||||
s64 priority = args->value;
|
||||
int err;
|
||||
|
||||
if (args->size)
|
||||
return -EINVAL;
|
||||
err = validate_priority(ctx->i915, args);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (!(ctx->i915->caps.scheduler & I915_SCHEDULER_CAP_PRIORITY))
|
||||
return -ENODEV;
|
||||
|
||||
if (priority > I915_CONTEXT_MAX_USER_PRIORITY ||
|
||||
priority < I915_CONTEXT_MIN_USER_PRIORITY)
|
||||
return -EINVAL;
|
||||
|
||||
if (priority > I915_CONTEXT_DEFAULT_PRIORITY &&
|
||||
!capable(CAP_SYS_NICE))
|
||||
return -EPERM;
|
||||
|
||||
ctx->sched.priority = priority;
|
||||
ctx->sched.priority = args->value;
|
||||
context_apply_all(ctx, __apply_priority, ctx);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue