drm/amdgpu: make amdgpu_to_sched_priority detect invalid parameters
authorAndres Rodriguez <andresx7@gmail.com>
Wed, 24 May 2017 21:00:10 +0000 (17:00 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 9 Oct 2017 20:30:22 +0000 (16:30 -0400)
Returning invalid priorities as _NORMAL is a backwards compatibility
quirk of amdgpu_ctx_ioctl(). Move this detail one layer up where it
belongs.

Signed-off-by: Andres Rodriguez <andresx7@gmail.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
drivers/gpu/drm/amd/scheduler/gpu_scheduler.h

index 52388b1b52c21c00a0521781b34157fc091e1e59..d3d63f78bec99e3a0037be50bdaa6eee85086770 100644 (file)
@@ -232,7 +232,7 @@ static enum amd_sched_priority amdgpu_to_sched_priority(int amdgpu_priority)
                return AMD_SCHED_PRIORITY_LOW;
        default:
                WARN(1, "Invalid context priority %d\n", amdgpu_priority);
-               return AMD_SCHED_PRIORITY_NORMAL;
+               return AMD_SCHED_PRIORITY_INVALID;
        }
 }
 
@@ -251,8 +251,10 @@ int amdgpu_ctx_ioctl(struct drm_device *dev, void *data,
        id = args->in.ctx_id;
        priority = amdgpu_to_sched_priority(args->in.priority);
 
-       if (priority >= AMD_SCHED_PRIORITY_MAX)
-               return -EINVAL;
+       /* For backwards compatibility reasons, we need to accept
+        * ioctls with garbage in the priority field */
+       if (priority == AMD_SCHED_PRIORITY_INVALID)
+               priority = AMD_SCHED_PRIORITY_NORMAL;
 
        switch (args->in.op) {
        case AMDGPU_CTX_OP_ALLOC_CTX:
index dbcaa2e1c5c742a3981c197c96c2d01b96c413e2..da040bc17e6147fcc07e3929c9509f5e97e33cc0 100644 (file)
@@ -120,7 +120,8 @@ enum amd_sched_priority {
        AMD_SCHED_PRIORITY_HIGH_SW,
        AMD_SCHED_PRIORITY_HIGH_HW,
        AMD_SCHED_PRIORITY_KERNEL,
-       AMD_SCHED_PRIORITY_MAX
+       AMD_SCHED_PRIORITY_MAX,
+       AMD_SCHED_PRIORITY_INVALID = -1
 };
 
 /**