]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
drm/amdgpu: Add command to override the context priority.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Wed, 30 Jan 2019 01:53:22 +0000 (02:53 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 15 Feb 2019 16:15:43 +0000 (11:15 -0500)
Given a master fd we can then override the priority of the context
in another fd.

Using these overrides was recommended by Christian instead of trying
to submit from a master fd, and I am adding a way to override a
single context instead of the entire process so we can only upgrade
a single Vulkan queue and not effectively the entire process.

Reused the flags field as it was checked to be 0 anyways, so nothing
used it. This is source-incompatible (due to the name change), but
ABI compatible.

Signed-off-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c
include/uapi/drm/amdgpu_drm.h

index 0b70410488b66cb270da578c7b1f82916f1bb23f..0767a93e4d9136c9f79bd46f1d041e4e7433ca1a 100644 (file)
@@ -76,6 +76,39 @@ static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev,
        return 0;
 }
 
+static int amdgpu_sched_context_priority_override(struct amdgpu_device *adev,
+                                                 int fd,
+                                                 unsigned ctx_id,
+                                                 enum drm_sched_priority priority)
+{
+       struct file *filp = fget(fd);
+       struct amdgpu_fpriv *fpriv;
+       struct amdgpu_ctx *ctx;
+       int r;
+
+       if (!filp)
+               return -EINVAL;
+
+       r = amdgpu_file_to_fpriv(filp, &fpriv);
+       if (r) {
+               fput(filp);
+               return r;
+       }
+
+       ctx = amdgpu_ctx_get(fpriv, ctx_id);
+
+       if (!ctx) {
+               fput(filp);
+               return -EINVAL;
+       }
+
+       amdgpu_ctx_priority_override(ctx, priority);
+       amdgpu_ctx_put(ctx);
+       fput(filp);
+
+       return 0;
+}
+
 int amdgpu_sched_ioctl(struct drm_device *dev, void *data,
                       struct drm_file *filp)
 {
@@ -85,7 +118,7 @@ int amdgpu_sched_ioctl(struct drm_device *dev, void *data,
        int r;
 
        priority = amdgpu_to_sched_priority(args->in.priority);
-       if (args->in.flags || priority == DRM_SCHED_PRIORITY_INVALID)
+       if (priority == DRM_SCHED_PRIORITY_INVALID)
                return -EINVAL;
 
        switch (args->in.op) {
@@ -94,6 +127,12 @@ int amdgpu_sched_ioctl(struct drm_device *dev, void *data,
                                                           args->in.fd,
                                                           priority);
                break;
+       case AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE:
+               r = amdgpu_sched_context_priority_override(adev,
+                                                          args->in.fd,
+                                                          args->in.ctx_id,
+                                                          priority);
+               break;
        default:
                DRM_ERROR("Invalid sched op specified: %d\n", args->in.op);
                r = -EINVAL;
index 2acbc8bc465b5f7dec98a0d687671f3317763259..4a53f6cfa0341590c3be9b84bb88d49b2d5d4994 100644 (file)
@@ -272,13 +272,14 @@ union drm_amdgpu_vm {
 
 /* sched ioctl */
 #define AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE      1
+#define AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE      2
 
 struct drm_amdgpu_sched_in {
        /* AMDGPU_SCHED_OP_* */
        __u32   op;
        __u32   fd;
        __s32   priority;
-       __u32   flags;
+       __u32   ctx_id;
 };
 
 union drm_amdgpu_sched {