Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Luben Tuikov <luben.tuikov@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Luben Tuikov and committed by
Alex Deucher
9af5e21d e2d732fd

+34 -15
+2 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
··· 388 388 struct amdgpu_device *adev = dev->dev_private; 389 389 struct amdgpu_fpriv *fpriv = filp->driver_priv; 390 390 391 - r = 0; 392 391 id = args->in.ctx_id; 393 - priority = amdgpu_to_sched_priority(args->in.priority); 392 + r = amdgpu_to_sched_priority(args->in.priority, &priority); 394 393 395 394 /* For backwards compatibility reasons, we need to accept 396 395 * ioctls with garbage in the priority field */ 397 - if (priority == DRM_SCHED_PRIORITY_INVALID) 396 + if (r == -EINVAL) 398 397 priority = DRM_SCHED_PRIORITY_NORMAL; 399 398 400 399 switch (args->in.op) {
+30 -10
drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c
··· 32 32 33 33 #include "amdgpu_vm.h" 34 34 35 - enum drm_sched_priority amdgpu_to_sched_priority(int amdgpu_priority) 35 + int amdgpu_to_sched_priority(int amdgpu_priority, 36 + enum drm_sched_priority *prio) 36 37 { 37 38 switch (amdgpu_priority) { 38 39 case AMDGPU_CTX_PRIORITY_VERY_HIGH: 39 - return DRM_SCHED_PRIORITY_HIGH; 40 + *prio = DRM_SCHED_PRIORITY_HIGH; 41 + break; 40 42 case AMDGPU_CTX_PRIORITY_HIGH: 41 - return DRM_SCHED_PRIORITY_HIGH; 43 + *prio = DRM_SCHED_PRIORITY_HIGH; 44 + break; 42 45 case AMDGPU_CTX_PRIORITY_NORMAL: 43 - return DRM_SCHED_PRIORITY_NORMAL; 46 + *prio = DRM_SCHED_PRIORITY_NORMAL; 47 + break; 44 48 case AMDGPU_CTX_PRIORITY_LOW: 45 49 case AMDGPU_CTX_PRIORITY_VERY_LOW: 46 - return DRM_SCHED_PRIORITY_MIN; 50 + *prio = DRM_SCHED_PRIORITY_MIN; 51 + break; 47 52 case AMDGPU_CTX_PRIORITY_UNSET: 48 - return DRM_SCHED_PRIORITY_UNSET; 53 + *prio = DRM_SCHED_PRIORITY_UNSET; 54 + break; 49 55 default: 50 56 WARN(1, "Invalid context priority %d\n", amdgpu_priority); 51 - return DRM_SCHED_PRIORITY_INVALID; 57 + return -EINVAL; 52 58 } 59 + 60 + return 0; 53 61 } 54 62 55 63 static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev, ··· 127 119 enum drm_sched_priority priority; 128 120 int r; 129 121 130 - priority = amdgpu_to_sched_priority(args->in.priority); 131 - if (priority == DRM_SCHED_PRIORITY_INVALID) 122 + /* First check the op, then the op's argument. 123 + */ 124 + switch (args->in.op) { 125 + case AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE: 126 + case AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE: 127 + break; 128 + default: 129 + DRM_ERROR("Invalid sched op specified: %d\n", args->in.op); 132 130 return -EINVAL; 131 + } 132 + 133 + r = amdgpu_to_sched_priority(args->in.priority, &priority); 134 + if (r) 135 + return r; 133 136 134 137 switch (args->in.op) { 135 138 case AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE: ··· 155 136 priority); 156 137 break; 157 138 default: 158 - DRM_ERROR("Invalid sched op specified: %d\n", args->in.op); 139 + /* Impossible. 140 + */ 159 141 r = -EINVAL; 160 142 break; 161 143 }
+2 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_sched.h
··· 30 30 struct drm_device; 31 31 struct drm_file; 32 32 33 - enum drm_sched_priority amdgpu_to_sched_priority(int amdgpu_priority); 33 + int amdgpu_to_sched_priority(int amdgpu_priority, 34 + enum drm_sched_priority *prio); 34 35 int amdgpu_sched_ioctl(struct drm_device *dev, void *data, 35 36 struct drm_file *filp); 36 37
-1
include/drm/gpu_scheduler.h
··· 43 43 DRM_SCHED_PRIORITY_KERNEL, 44 44 45 45 DRM_SCHED_PRIORITY_COUNT, 46 - DRM_SCHED_PRIORITY_INVALID = -1, 47 46 DRM_SCHED_PRIORITY_UNSET = -2 48 47 }; 49 48