Commit 51358444 authored by Sunil Khatri's avatar Sunil Khatri Committed by Alex Deucher
Browse files

drm/amdgpu/userq: dont lock root bo with userq_mutex held



Do not hold reservation lock for root bo if userq_mutex
is already held in the call flow this cause a lock
issue with ttm_bo_delayed_delete.

Its better to lock the vm->root.bo first and then go ahead
with userq_mutex so userq_mutex threads dont get stuck until
the reservation lock is held.

In this case it helps in the function amdgpu_userq_buffer_vas_mapped
for each queue during restore_all.

Signed-off-by: default avatarSunil Khatri <sunil.khatri@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 1eb90c74
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -270,15 +270,13 @@ static bool amdgpu_userq_buffer_va_mapped(struct amdgpu_vm *vm, u64 addr)
	struct amdgpu_bo_va_mapping *mapping;
	bool r;

	if (amdgpu_bo_reserve(vm->root.bo, false))
		return false;
	dma_resv_assert_held(vm->root.bo->tbo.base.resv);

	mapping = amdgpu_vm_bo_lookup_mapping(vm, addr);
	if (!IS_ERR_OR_NULL(mapping) && atomic_read(&mapping->bo_va->userq_va_mapped))
		r = true;
	else
		r = false;
	amdgpu_bo_unreserve(vm->root.bo);

	return r;
}
@@ -991,10 +989,16 @@ int amdgpu_userq_ioctl(struct drm_device *dev, void *data,
static int
amdgpu_userq_restore_all(struct amdgpu_userq_mgr *uq_mgr)
{
	struct amdgpu_fpriv *fpriv = uq_mgr_to_fpriv(uq_mgr);
	struct amdgpu_vm *vm = &fpriv->vm;
	struct amdgpu_usermode_queue *queue;
	unsigned long queue_id;
	int ret = 0, r;


	if (amdgpu_bo_reserve(vm->root.bo, false))
		return false;

	mutex_lock(&uq_mgr->userq_mutex);
	/* Resume all the queues for this process */
	xa_for_each(&uq_mgr->userq_xa, queue_id, queue) {
@@ -1012,6 +1016,7 @@ amdgpu_userq_restore_all(struct amdgpu_userq_mgr *uq_mgr)

	}
	mutex_unlock(&uq_mgr->userq_mutex);
	amdgpu_bo_unreserve(vm->root.bo);

	if (ret)
		drm_file_err(uq_mgr->file,