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

drm/amdgpu: validate VM PTs only on eviction

We don't need to validate them again if the eviction counter didn't changed.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Christian König and committed by
Alex Deucher
5a712a87 dbd5ed60

+20 -4
+3 -1
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 864 864 struct amdgpu_bo *page_directory; 865 865 unsigned max_pde_used; 866 866 struct fence *page_directory_fence; 867 + uint64_t last_eviction_counter; 867 868 868 869 /* array of page tables, one for each page directory entry */ 869 870 struct amdgpu_vm_pt *page_tables; ··· 933 932 void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm, 934 933 struct list_head *validated, 935 934 struct amdgpu_bo_list_entry *entry); 936 - void amdgpu_vm_get_pt_bos(struct amdgpu_vm *vm, struct list_head *duplicates); 935 + void amdgpu_vm_get_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, 936 + struct list_head *duplicates); 937 937 void amdgpu_vm_move_pt_bos_in_lru(struct amdgpu_device *adev, 938 938 struct amdgpu_vm *vm); 939 939 int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
+4 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
··· 459 459 list_splice(&need_pages, &p->validated); 460 460 } 461 461 462 - amdgpu_vm_get_pt_bos(&fpriv->vm, &duplicates); 462 + amdgpu_vm_get_pt_bos(p->adev, &fpriv->vm, &duplicates); 463 463 464 464 p->bytes_moved_threshold = amdgpu_cs_get_threshold_for_moves(p->adev); 465 465 p->bytes_moved = 0; ··· 471 471 r = amdgpu_cs_list_validate(p, &p->validated); 472 472 if (r) 473 473 goto error_validate; 474 + 475 + fpriv->vm.last_eviction_counter = 476 + atomic64_read(&p->adev->num_evictions); 474 477 475 478 if (p->bo_list) { 476 479 struct amdgpu_bo *gds = p->bo_list->gds_obj;
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
··· 503 503 if (r) 504 504 goto error_print; 505 505 506 - amdgpu_vm_get_pt_bos(bo_va->vm, &duplicates); 506 + amdgpu_vm_get_pt_bos(adev, bo_va->vm, &duplicates); 507 507 list_for_each_entry(entry, &list, head) { 508 508 domain = amdgpu_mem_type_to_domain(entry->bo->mem.mem_type); 509 509 /* if anything is swapped out don't swap it in here,
+12 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
··· 115 115 /** 116 116 * amdgpu_vm_get_bos - add the vm BOs to a duplicates list 117 117 * 118 + * @adev: amdgpu device pointer 118 119 * @vm: vm providing the BOs 119 120 * @duplicates: head of duplicates list 120 121 * 121 122 * Add the page directory to the BO duplicates list 122 123 * for command submission. 123 124 */ 124 - void amdgpu_vm_get_pt_bos(struct amdgpu_vm *vm, struct list_head *duplicates) 125 + void amdgpu_vm_get_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, 126 + struct list_head *duplicates) 125 127 { 128 + uint64_t num_evictions; 126 129 unsigned i; 130 + 131 + /* We only need to validate the page tables 132 + * if they aren't already valid. 133 + */ 134 + num_evictions = atomic64_read(&adev->num_evictions); 135 + if (num_evictions == vm->last_eviction_counter) 136 + return; 127 137 128 138 /* add the vm page table to the list */ 129 139 for (i = 0; i <= vm->max_pde_used; ++i) { ··· 1544 1534 amdgpu_bo_unreserve(vm->page_directory); 1545 1535 if (r) 1546 1536 goto error_free_page_directory; 1537 + vm->last_eviction_counter = atomic64_read(&adev->num_evictions); 1547 1538 1548 1539 return 0; 1549 1540