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

drm/amdgpu: userq_va_mapped should remain true once done



Multiple queues needs these bo_va objects belonging to
the same uq_mgr. So once they are mapped lets not unmap
them as at any point of time any of the queues might be
using it.

Also userq_va_mapped should be a boolean than atomic.

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>
(cherry picked from commit 5c02889ea22575c3bcfdf212e65fac316cbc6c6a)
parent cd7cfcdb
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -96,7 +96,8 @@ struct amdgpu_bo_va {
	 * if non-zero, cannot unmap from GPU because user queues may still access it
	 */
	unsigned int			queue_refcount;
	atomic_t			userq_va_mapped;
	/* Indicates if this buffer is mapped for any user queue. Once set, never reset. */
	bool				userq_va_mapped;
};

struct amdgpu_bo {
+4 −12
Original line number Diff line number Diff line
@@ -227,7 +227,7 @@ static int amdgpu_userq_buffer_va_list_add(struct amdgpu_usermode_queue *queue,

	INIT_LIST_HEAD(&va_cursor->list);
	va_cursor->gpu_addr = addr;
	atomic_set(&va_map->bo_va->userq_va_mapped, 1);
	va_map->bo_va->userq_va_mapped = true;
	list_add(&va_cursor->list, &queue->userq_va_list);

	return 0;
@@ -274,7 +274,7 @@ static bool amdgpu_userq_buffer_va_mapped(struct amdgpu_vm *vm, u64 addr)
	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))
	if (!IS_ERR_OR_NULL(mapping) && mapping->bo_va->userq_va_mapped)
		r = true;
	else
		r = false;
@@ -300,15 +300,6 @@ static bool amdgpu_userq_buffer_vas_mapped(struct amdgpu_usermode_queue *queue)
	return false;
}

static void amdgpu_userq_buffer_va_list_del(struct amdgpu_bo_va_mapping *mapping,
					    struct amdgpu_userq_va_cursor *va_cursor)
{
	if (mapping)
		atomic_set(&mapping->bo_va->userq_va_mapped, 0);
	list_del(&va_cursor->list);
	kfree(va_cursor);
}

static void amdgpu_userq_buffer_vas_list_cleanup(struct amdgpu_device *adev,
						 struct amdgpu_usermode_queue *queue)
{
@@ -323,7 +314,8 @@ static void amdgpu_userq_buffer_vas_list_cleanup(struct amdgpu_device *adev,
		if (mapping)
			dev_dbg(adev->dev, "delete the userq:%p va:%llx\n",
				queue, va_cursor->gpu_addr);
		amdgpu_userq_buffer_va_list_del(mapping, va_cursor);
		list_del(&va_cursor->list);
		kfree(va_cursor);
	}
}

+1 −1
Original line number Diff line number Diff line
@@ -2002,7 +2002,7 @@ int amdgpu_vm_bo_unmap(struct amdgpu_device *adev,
	 * during user requests GEM unmap IOCTL except for forcing the unmap
	 * from user space.
	 */
	if (unlikely(atomic_read(&bo_va->userq_va_mapped) > 0))
	if (unlikely(bo_va->userq_va_mapped))
		amdgpu_userq_gem_va_unmap_validate(adev, mapping, saddr);

	list_del(&mapping->list);