drm/amdgpu: make VMID assignment more fair v2
authorChristian König <christian.koenig@amd.com>
Wed, 31 Jan 2018 09:16:26 +0000 (10:16 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 19 Feb 2018 19:19:13 +0000 (14:19 -0500)
Similar to finding an idle one before reuse.

This guarantees fairness between processes. Otherwise process with a reserved
VMID have an unfair advantage while scheduling jobs.

v2: improve commit message

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

index c13cf7e79b2ef445337afea20bc18e73c43ecc70..7a3d0de7425d486f90c7c11db5ffaa0ccf42d45e 100644 (file)
@@ -268,11 +268,6 @@ int amdgpu_vmid_grab(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
        int r = 0;
 
        mutex_lock(&id_mgr->lock);
-       if (vm->reserved_vmid[vmhub]) {
-               r = amdgpu_vmid_grab_reserved_locked(vm, ring, sync, fence, job);
-               mutex_unlock(&id_mgr->lock);
-               return r;
-       }
        fences = kmalloc_array(sizeof(void *), id_mgr->num_ids, GFP_KERNEL);
        if (!fences) {
                mutex_unlock(&id_mgr->lock);
@@ -319,6 +314,13 @@ int amdgpu_vmid_grab(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
        }
        kfree(fences);
 
+       if (vm->reserved_vmid[vmhub]) {
+               r = amdgpu_vmid_grab_reserved_locked(vm, ring, sync,
+                                                    fence, job);
+               mutex_unlock(&id_mgr->lock);
+               return r;
+       }
+
        job->vm_needs_flush = vm->use_cpu_for_update;
        /* Check if we can use a VMID already assigned to this VM */
        list_for_each_entry_reverse(id, &id_mgr->ids_lru, list) {