Commit 9af5e21d authored by Luben Tuikov's avatar Luben Tuikov Committed by Alex Deucher

drm/scheduler: Remove priority macro INVALID (v2)

Remove DRM_SCHED_PRIORITY_INVALID. We no longer
carry around an invalid priority and cut it off
at the source.

Backwards compatibility behaviour of AMDGPU CTX
IOCTL passing in garbage for context priority
from user space and then mapping that to
DRM_SCHED_PRIORITY_NORMAL is preserved.

v2: Revert "res"  --> "r" and
           "prio" --> "priority".
Signed-off-by: default avatarLuben Tuikov <luben.tuikov@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent e2d732fd
...@@ -388,13 +388,12 @@ int amdgpu_ctx_ioctl(struct drm_device *dev, void *data, ...@@ -388,13 +388,12 @@ int amdgpu_ctx_ioctl(struct drm_device *dev, void *data,
struct amdgpu_device *adev = dev->dev_private; struct amdgpu_device *adev = dev->dev_private;
struct amdgpu_fpriv *fpriv = filp->driver_priv; struct amdgpu_fpriv *fpriv = filp->driver_priv;
r = 0;
id = args->in.ctx_id; id = args->in.ctx_id;
priority = amdgpu_to_sched_priority(args->in.priority); r = amdgpu_to_sched_priority(args->in.priority, &priority);
/* For backwards compatibility reasons, we need to accept /* For backwards compatibility reasons, we need to accept
* ioctls with garbage in the priority field */ * ioctls with garbage in the priority field */
if (priority == DRM_SCHED_PRIORITY_INVALID) if (r == -EINVAL)
priority = DRM_SCHED_PRIORITY_NORMAL; priority = DRM_SCHED_PRIORITY_NORMAL;
switch (args->in.op) { switch (args->in.op) {
......
...@@ -32,24 +32,32 @@ ...@@ -32,24 +32,32 @@
#include "amdgpu_vm.h" #include "amdgpu_vm.h"
enum drm_sched_priority amdgpu_to_sched_priority(int amdgpu_priority) int amdgpu_to_sched_priority(int amdgpu_priority,
enum drm_sched_priority *prio)
{ {
switch (amdgpu_priority) { switch (amdgpu_priority) {
case AMDGPU_CTX_PRIORITY_VERY_HIGH: case AMDGPU_CTX_PRIORITY_VERY_HIGH:
return DRM_SCHED_PRIORITY_HIGH; *prio = DRM_SCHED_PRIORITY_HIGH;
break;
case AMDGPU_CTX_PRIORITY_HIGH: case AMDGPU_CTX_PRIORITY_HIGH:
return DRM_SCHED_PRIORITY_HIGH; *prio = DRM_SCHED_PRIORITY_HIGH;
break;
case AMDGPU_CTX_PRIORITY_NORMAL: case AMDGPU_CTX_PRIORITY_NORMAL:
return DRM_SCHED_PRIORITY_NORMAL; *prio = DRM_SCHED_PRIORITY_NORMAL;
break;
case AMDGPU_CTX_PRIORITY_LOW: case AMDGPU_CTX_PRIORITY_LOW:
case AMDGPU_CTX_PRIORITY_VERY_LOW: case AMDGPU_CTX_PRIORITY_VERY_LOW:
return DRM_SCHED_PRIORITY_MIN; *prio = DRM_SCHED_PRIORITY_MIN;
break;
case AMDGPU_CTX_PRIORITY_UNSET: case AMDGPU_CTX_PRIORITY_UNSET:
return DRM_SCHED_PRIORITY_UNSET; *prio = DRM_SCHED_PRIORITY_UNSET;
break;
default: default:
WARN(1, "Invalid context priority %d\n", amdgpu_priority); WARN(1, "Invalid context priority %d\n", amdgpu_priority);
return DRM_SCHED_PRIORITY_INVALID; return -EINVAL;
} }
return 0;
} }
static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev, static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev,
...@@ -119,9 +127,20 @@ int amdgpu_sched_ioctl(struct drm_device *dev, void *data, ...@@ -119,9 +127,20 @@ int amdgpu_sched_ioctl(struct drm_device *dev, void *data,
enum drm_sched_priority priority; enum drm_sched_priority priority;
int r; int r;
priority = amdgpu_to_sched_priority(args->in.priority); /* First check the op, then the op's argument.
if (priority == DRM_SCHED_PRIORITY_INVALID) */
switch (args->in.op) {
case AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE:
case AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE:
break;
default:
DRM_ERROR("Invalid sched op specified: %d\n", args->in.op);
return -EINVAL; return -EINVAL;
}
r = amdgpu_to_sched_priority(args->in.priority, &priority);
if (r)
return r;
switch (args->in.op) { switch (args->in.op) {
case AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE: case AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE:
...@@ -136,7 +155,8 @@ int amdgpu_sched_ioctl(struct drm_device *dev, void *data, ...@@ -136,7 +155,8 @@ int amdgpu_sched_ioctl(struct drm_device *dev, void *data,
priority); priority);
break; break;
default: default:
DRM_ERROR("Invalid sched op specified: %d\n", args->in.op); /* Impossible.
*/
r = -EINVAL; r = -EINVAL;
break; break;
} }
......
...@@ -30,7 +30,8 @@ enum drm_sched_priority; ...@@ -30,7 +30,8 @@ enum drm_sched_priority;
struct drm_device; struct drm_device;
struct drm_file; struct drm_file;
enum drm_sched_priority amdgpu_to_sched_priority(int amdgpu_priority); int amdgpu_to_sched_priority(int amdgpu_priority,
enum drm_sched_priority *prio);
int amdgpu_sched_ioctl(struct drm_device *dev, void *data, int amdgpu_sched_ioctl(struct drm_device *dev, void *data,
struct drm_file *filp); struct drm_file *filp);
......
...@@ -43,7 +43,6 @@ enum drm_sched_priority { ...@@ -43,7 +43,6 @@ enum drm_sched_priority {
DRM_SCHED_PRIORITY_KERNEL, DRM_SCHED_PRIORITY_KERNEL,
DRM_SCHED_PRIORITY_COUNT, DRM_SCHED_PRIORITY_COUNT,
DRM_SCHED_PRIORITY_INVALID = -1,
DRM_SCHED_PRIORITY_UNSET = -2 DRM_SCHED_PRIORITY_UNSET = -2
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment