drm/amdgpu: prefer VMIDs idle on the current ring
authorChristian König <christian.koenig@amd.com>
Mon, 23 May 2016 13:30:08 +0000 (15:30 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 7 Jul 2016 18:51:22 +0000 (14:51 -0400)
Prefer to use a VMIDs which are idle on the ring we want to submit to. This
also removes bubbling idle VMIDs up on the LRU, which is actually not
beneficial.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
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_vm.c

index 711d92bb7ae278c93544ed69b4227e2116fbcb21..cf989cf54072d682193ff311f4c970565e3de7ca 100644 (file)
@@ -236,21 +236,15 @@ int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
 
        } while (i != ring->idx);
 
-       id = list_first_entry(&adev->vm_manager.ids_lru,
-                             struct amdgpu_vm_id,
-                             list);
-
-       if (!amdgpu_sync_is_idle(&id->active, NULL)) {
-               struct list_head *head = &adev->vm_manager.ids_lru;
-               struct amdgpu_vm_id *tmp;
-
-               list_for_each_entry_safe(id, tmp, &adev->vm_manager.ids_lru,
-                                        list) {
-                       if (amdgpu_sync_is_idle(&id->active, NULL)) {
-                               list_move(&id->list, head);
-                               head = &id->list;
-                       }
-               }
+       /* Check if we have an idle VMID */
+       list_for_each_entry(id, &adev->vm_manager.ids_lru, list) {
+               if (amdgpu_sync_is_idle(&id->active, ring))
+                       break;
+
+       }
+
+       /* If we can't find a idle VMID to use, just wait for the oldest */
+       if (&id->list == &adev->vm_manager.ids_lru) {
                id = list_first_entry(&adev->vm_manager.ids_lru,
                                      struct amdgpu_vm_id,
                                      list);