Commit d00e9cc2 authored by Thomas Hellström's avatar Thomas Hellström Committed by Rodrigo Vivi
Browse files

drm/xe/vm: Simplify and document xe_vm_lock()



The xe_vm_lock() function was unnecessarily using ttm_eu_reserve_buffers().
Simplify and document the interface.

v4:
- Improve on xe_vm_lock() documentation (Matthew Brost)
v5:
- Rebase conflict.

Signed-off-by: default avatarThomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: default avatarMatthew Brost <matthew.brost@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230908091716.36984-3-thomas.hellstrom@linux.intel.com


Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent 08a4f00e
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -180,7 +180,6 @@ static int evict_test_run_tile(struct xe_device *xe, struct xe_tile *tile, struc
	unsigned int bo_flags = XE_BO_CREATE_USER_BIT |
		XE_BO_CREATE_VRAM_IF_DGFX(tile);
	struct xe_vm *vm = xe_migrate_get_vm(xe_device_get_root_tile(xe)->migrate);
	struct ww_acquire_ctx ww;
	struct xe_gt *__gt;
	int err, i, id;

@@ -188,10 +187,10 @@ static int evict_test_run_tile(struct xe_device *xe, struct xe_tile *tile, struc
		   dev_name(xe->drm.dev), tile->id);

	for (i = 0; i < 2; ++i) {
		xe_vm_lock(vm, &ww, 0, false);
		xe_vm_lock(vm, false);
		bo = xe_bo_create(xe, NULL, vm, 0x10000, ttm_bo_type_device,
				  bo_flags);
		xe_vm_unlock(vm, &ww);
		xe_vm_unlock(vm);
		if (IS_ERR(bo)) {
			KUNIT_FAIL(test, "bo create err=%pe\n", bo);
			break;
@@ -263,9 +262,9 @@ static int evict_test_run_tile(struct xe_device *xe, struct xe_tile *tile, struc

		if (i) {
			down_read(&vm->lock);
			xe_vm_lock(vm, &ww, 0, false);
			xe_vm_lock(vm, false);
			err = xe_bo_validate(bo, bo->vm, false);
			xe_vm_unlock(vm, &ww);
			xe_vm_unlock(vm);
			up_read(&vm->lock);
			if (err) {
				KUNIT_FAIL(test, "bo valid err=%pe\n",
+2 −3
Original line number Diff line number Diff line
@@ -396,14 +396,13 @@ static int migrate_test_run_device(struct xe_device *xe)

	for_each_tile(tile, xe, id) {
		struct xe_migrate *m = tile->migrate;
		struct ww_acquire_ctx ww;

		kunit_info(test, "Testing tile id %d.\n", id);
		xe_vm_lock(m->q->vm, &ww, 0, true);
		xe_vm_lock(m->q->vm, true);
		xe_device_mem_access_get(xe);
		xe_migrate_sanity_test(m, test);
		xe_device_mem_access_put(xe);
		xe_vm_unlock(m->q->vm, &ww);
		xe_vm_unlock(m->q->vm);
	}

	return 0;
+2 −3
Original line number Diff line number Diff line
@@ -1759,7 +1759,6 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
	struct xe_device *xe = to_xe_device(dev);
	struct xe_file *xef = to_xe_file(file);
	struct drm_xe_gem_create *args = data;
	struct ww_acquire_ctx ww;
	struct xe_vm *vm = NULL;
	struct xe_bo *bo;
	unsigned int bo_flags = XE_BO_CREATE_USER_BIT;
@@ -1812,7 +1811,7 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
		vm = xe_vm_lookup(xef, args->vm_id);
		if (XE_IOCTL_DBG(xe, !vm))
			return -ENOENT;
		err = xe_vm_lock(vm, &ww, 0, true);
		err = xe_vm_lock(vm, true);
		if (err) {
			xe_vm_put(vm);
			return err;
@@ -1840,7 +1839,7 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
	xe_bo_put(bo);
out_vm:
	if (vm) {
		xe_vm_unlock(vm, &ww);
		xe_vm_unlock(vm);
		xe_vm_put(vm);
	}
	return err;
+2 −3
Original line number Diff line number Diff line
@@ -111,18 +111,17 @@ struct xe_exec_queue *xe_exec_queue_create(struct xe_device *xe, struct xe_vm *v
					   u32 logical_mask, u16 width,
					   struct xe_hw_engine *hwe, u32 flags)
{
	struct ww_acquire_ctx ww;
	struct xe_exec_queue *q;
	int err;

	if (vm) {
		err = xe_vm_lock(vm, &ww, 0, true);
		err = xe_vm_lock(vm, true);
		if (err)
			return ERR_PTR(err);
	}
	q = __xe_exec_queue_create(xe, vm, logical_mask, width, hwe, flags);
	if (vm)
		xe_vm_unlock(vm, &ww);
		xe_vm_unlock(vm);

	return q;
}
+2 −4
Original line number Diff line number Diff line
@@ -789,16 +789,14 @@ int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,

void xe_lrc_finish(struct xe_lrc *lrc)
{
	struct ww_acquire_ctx ww;

	xe_hw_fence_ctx_finish(&lrc->fence_ctx);
	if (lrc->bo->vm)
		xe_vm_lock(lrc->bo->vm, &ww, 0, false);
		xe_vm_lock(lrc->bo->vm, false);
	else
		xe_bo_lock_no_vm(lrc->bo, NULL);
	xe_bo_unpin(lrc->bo);
	if (lrc->bo->vm)
		xe_vm_unlock(lrc->bo->vm, &ww);
		xe_vm_unlock(lrc->bo->vm);
	else
		xe_bo_unlock_no_vm(lrc->bo);
	xe_bo_put(lrc->bo);
Loading