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: avoid uneccessary locking in amdgpu_userq_create

Reorganise code to avoid holding mutex userq_mutex while
also trying to grab exec lock ww_mutex where its not needed
for function amdgpu_userq_input_va_validate

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
a7fe8c1b 732a8add

+12 -16
+12 -16
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
··· 737 737 return r; 738 738 } 739 739 740 - /* 741 - * There could be a situation that we are creating a new queue while 742 - * the other queues under this UQ_mgr are suspended. So if there is any 743 - * resume work pending, wait for it to get done. 744 - * 745 - * This will also make sure we have a valid eviction fence ready to be used. 746 - */ 747 - amdgpu_userq_ensure_ev_fence(&fpriv->userq_mgr, &fpriv->evf_mgr); 748 - 749 740 uq_funcs = adev->userq_funcs[args->in.ip_type]; 750 741 if (!uq_funcs) { 751 742 drm_file_err(uq_mgr->file, "Usermode queue is not supported for this IP (%u)\n", 752 743 args->in.ip_type); 753 - r = -EINVAL; 754 - goto unlock; 744 + return -EINVAL; 755 745 } 756 746 757 747 queue = kzalloc_obj(struct amdgpu_usermode_queue); 758 748 if (!queue) { 759 749 drm_file_err(uq_mgr->file, "Failed to allocate memory for queue\n"); 760 - r = -ENOMEM; 761 - goto unlock; 750 + return -ENOMEM; 762 751 } 763 752 764 753 INIT_LIST_HEAD(&queue->userq_va_list); ··· 785 796 drm_file_err(uq_mgr->file, "Failed to alloc fence driver\n"); 786 797 goto free_queue; 787 798 } 799 + 800 + /* 801 + * There could be a situation that we are creating a new queue while 802 + * the other queues under this UQ_mgr are suspended. So if there is any 803 + * resume work pending, wait for it to get done. 804 + * 805 + * This will also make sure we have a valid eviction fence ready to be used. 806 + */ 807 + amdgpu_userq_ensure_ev_fence(&fpriv->userq_mgr, &fpriv->evf_mgr); 788 808 789 809 r = uq_funcs->mqd_create(queue, &args->in); 790 810 if (r) { ··· 856 858 up_read(&adev->reset_domain->sem); 857 859 clean_fence_driver: 858 860 amdgpu_userq_fence_driver_free(queue); 861 + mutex_unlock(&uq_mgr->userq_mutex); 859 862 free_queue: 860 863 kfree(queue); 861 - unlock: 862 - mutex_unlock(&uq_mgr->userq_mutex); 863 - 864 864 return r; 865 865 } 866 866