drm/amdgpu: allow for more flexible priority handling
authorChristian König <christian.koenig@amd.com>
Mon, 16 Jul 2018 11:47:34 +0000 (13:47 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 18 Jul 2018 21:18:43 +0000 (16:18 -0500)
Allow to call amdgpu_ring_priority_get() after pushing the ring to the
scheduler.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c

index 19e45a3953e07d3ac69bd84cbb86bfa1f7cd0b21..93794a85f83d80e868870133e387467c2b8de4a9 100644 (file)
@@ -211,7 +211,8 @@ void amdgpu_ring_priority_get(struct amdgpu_ring *ring,
        if (!ring->funcs->set_priority)
                return;
 
-       atomic_inc(&ring->num_jobs[priority]);
+       if (atomic_inc_return(&ring->num_jobs[priority]) <= 0)
+               return;
 
        mutex_lock(&ring->priority_mutex);
        if (priority <= ring->priority)