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

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdgpu/userq: caller to take reserv lock for vas_list_cleanup

In function amdgpu_userq_buffer_vas_list_cleanup, remove the
reservation lock for vm and caller should make sure it's taken
before locking userq_mutex.

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

authored by

Sunil Khatri and committed by
Alex Deucher
168178b0 469e6fea

+18 -12
+18 -12
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
··· 312 312 { 313 313 struct amdgpu_userq_va_cursor *va_cursor, *tmp; 314 314 struct amdgpu_bo_va_mapping *mapping; 315 - int r; 316 315 317 - r = amdgpu_bo_reserve(queue->vm->root.bo, false); 318 - if (r) 319 - return r; 316 + /* Caller must hold vm->root.bo reservation */ 317 + dma_resv_assert_held(queue->vm->root.bo->tbo.base.resv); 320 318 321 319 list_for_each_entry_safe(va_cursor, tmp, &queue->userq_va_list, list) { 322 320 mapping = amdgpu_vm_bo_lookup_mapping(queue->vm, va_cursor->gpu_addr); 323 321 if (!mapping) { 324 - r = -EINVAL; 325 - goto err; 322 + return -EINVAL; 326 323 } 327 324 dev_dbg(adev->dev, "delete the userq:%p va:%llx\n", 328 325 queue, va_cursor->gpu_addr); 329 326 amdgpu_userq_buffer_va_list_del(mapping, va_cursor); 330 327 } 331 - err: 332 - amdgpu_bo_unreserve(queue->vm->root.bo); 333 - return r; 328 + 329 + return 0; 334 330 } 335 331 336 332 static int amdgpu_userq_preempt_helper(struct amdgpu_usermode_queue *queue) ··· 440 444 /* Wait for mode-1 reset to complete */ 441 445 down_read(&adev->reset_domain->sem); 442 446 443 - /* Drop the userq reference. */ 444 - amdgpu_userq_buffer_vas_list_cleanup(adev, queue); 445 447 uq_funcs->mqd_destroy(queue); 446 448 /* Use interrupt-safe locking since IRQ handlers may access these XArrays */ 447 449 xa_erase_irq(&adev->userq_doorbell_xa, queue->doorbell_index); ··· 620 626 amdgpu_userq_destroy(struct amdgpu_userq_mgr *uq_mgr, struct amdgpu_usermode_queue *queue) 621 627 { 622 628 struct amdgpu_device *adev = uq_mgr->adev; 629 + struct amdgpu_fpriv *fpriv = uq_mgr_to_fpriv(uq_mgr); 630 + struct amdgpu_vm *vm = &fpriv->vm; 631 + 623 632 int r = 0; 624 633 625 634 cancel_delayed_work_sync(&uq_mgr->resume_work); 626 635 627 636 /* Cancel any pending hang detection work and cleanup */ 628 637 cancel_delayed_work_sync(&queue->hang_detect_work); 638 + 639 + r = amdgpu_bo_reserve(vm->root.bo, false); 640 + if (r) { 641 + drm_file_err(uq_mgr->file, "Failed to reserve root bo during userqueue destroy\n"); 642 + return r; 643 + } 644 + amdgpu_userq_buffer_vas_list_cleanup(adev, queue); 645 + amdgpu_bo_unreserve(vm->root.bo); 629 646 630 647 mutex_lock(&uq_mgr->userq_mutex); 631 648 queue->hang_detect_fence = NULL; ··· 669 664 } 670 665 amdgpu_userq_cleanup(queue); 671 666 mutex_unlock(&uq_mgr->userq_mutex); 672 - 673 667 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); 674 668 675 669 return r; ··· 860 856 clean_fence_driver: 861 857 amdgpu_userq_fence_driver_free(queue); 862 858 clean_mapping: 859 + amdgpu_bo_reserve(fpriv->vm.root.bo, true); 863 860 amdgpu_userq_buffer_vas_list_cleanup(adev, queue); 861 + amdgpu_bo_unreserve(fpriv->vm.root.bo); 864 862 kfree(queue); 865 863 return r; 866 864 }