Commit 59b00024 authored by Dave Airlie's avatar Dave Airlie
Browse files

Merge tag 'drm-xe-fixes-2025-08-27' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-fixes



- Fix user-fence race issue (Zbigniew)
- Couple xe_vm fixes (Thomas)
- Don't trigger rebind on initial dma-buf validation (Brost)
- Fix a build issue related to basename() posix vs gnu discrepancy (Carlos)

Signed-off-by: default avatarDave Airlie <airlied@redhat.com>

From: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://lore.kernel.org/r/aK8oalcIU-zQOfws@intel.com
parents 1b237f19 75671d90
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -812,6 +812,7 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict,
	}

	if (ttm_bo->type == ttm_bo_type_sg) {
		if (new_mem->mem_type == XE_PL_SYSTEM)
			ret = xe_bo_move_notify(bo, ctx);
		if (!ret)
			ret = xe_bo_move_dmabuf(ttm_bo, new_mem);
@@ -2438,7 +2439,6 @@ int xe_bo_validate(struct xe_bo *bo, struct xe_vm *vm, bool allow_res_evict)
		.no_wait_gpu = false,
		.gfp_retry_mayfail = true,
	};
	struct pin_cookie cookie;
	int ret;

	if (vm) {
@@ -2449,10 +2449,10 @@ int xe_bo_validate(struct xe_bo *bo, struct xe_vm *vm, bool allow_res_evict)
		ctx.resv = xe_vm_resv(vm);
	}

	cookie = xe_vm_set_validating(vm, allow_res_evict);
	xe_vm_set_validating(vm, allow_res_evict);
	trace_xe_bo_validate(bo);
	ret = ttm_bo_validate(&bo->ttm, &bo->placement, &ctx);
	xe_vm_clear_validating(vm, allow_res_evict, cookie);
	xe_vm_clear_validating(vm, allow_res_evict);

	return ret;
}
+9 −1
Original line number Diff line number Diff line
@@ -123,11 +123,19 @@ static int parse(FILE *input, FILE *csource, FILE *cheader, char *prefix)
	return 0;
}

/* Avoid GNU vs POSIX basename() discrepancy, just use our own */
static const char *xbasename(const char *s)
{
	const char *p = strrchr(s, '/');

	return p ? p + 1 : s;
}

static int fn_to_prefix(const char *fn, char *prefix, size_t size)
{
	size_t len;

	fn = basename(fn);
	fn = xbasename(fn);
	len = strlen(fn);

	if (len > size - 1)
+1 −1
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ static void user_fence_worker(struct work_struct *w)
{
	struct xe_user_fence *ufence = container_of(w, struct xe_user_fence, worker);

	WRITE_ONCE(ufence->signalled, 1);
	if (mmget_not_zero(ufence->mm)) {
		kthread_use_mm(ufence->mm);
		if (copy_to_user(ufence->addr, &ufence->value, sizeof(ufence->value)))
@@ -91,7 +92,6 @@ static void user_fence_worker(struct work_struct *w)
	 * Wake up waiters only after updating the ufence state, allowing the UMD
	 * to safely reuse the same ufence without encountering -EBUSY errors.
	 */
	WRITE_ONCE(ufence->signalled, 1);
	wake_up_all(&ufence->xe->ufence_wq);
	user_fence_put(ufence);
}
+6 −2
Original line number Diff line number Diff line
@@ -1610,8 +1610,12 @@ static int xe_vm_create_scratch(struct xe_device *xe, struct xe_tile *tile,

	for (i = MAX_HUGEPTE_LEVEL; i < vm->pt_root[id]->level; i++) {
		vm->scratch_pt[id][i] = xe_pt_create(vm, tile, i);
		if (IS_ERR(vm->scratch_pt[id][i]))
			return PTR_ERR(vm->scratch_pt[id][i]);
		if (IS_ERR(vm->scratch_pt[id][i])) {
			int err = PTR_ERR(vm->scratch_pt[id][i]);

			vm->scratch_pt[id][i] = NULL;
			return err;
		}

		xe_pt_populate_empty(tile, vm, vm->scratch_pt[id][i]);
	}
+2 −13
Original line number Diff line number Diff line
@@ -315,22 +315,14 @@ void xe_vm_snapshot_free(struct xe_vm_snapshot *snap);
 * Register this task as currently making bos resident for the vm. Intended
 * to avoid eviction by the same task of shared bos bound to the vm.
 * Call with the vm's resv lock held.
 *
 * Return: A pin cookie that should be used for xe_vm_clear_validating().
 */
static inline struct pin_cookie xe_vm_set_validating(struct xe_vm *vm,
						     bool allow_res_evict)
static inline void xe_vm_set_validating(struct xe_vm *vm, bool allow_res_evict)
{
	struct pin_cookie cookie = {};

	if (vm && !allow_res_evict) {
		xe_vm_assert_held(vm);
		cookie = lockdep_pin_lock(&xe_vm_resv(vm)->lock.base);
		/* Pairs with READ_ONCE in xe_vm_is_validating() */
		WRITE_ONCE(vm->validating, current);
	}

	return cookie;
}

/**
@@ -338,17 +330,14 @@ static inline struct pin_cookie xe_vm_set_validating(struct xe_vm *vm,
 * @vm: Pointer to the vm or NULL
 * @allow_res_evict: Eviction from @vm was allowed. Must be set to the same
 * value as for xe_vm_set_validation().
 * @cookie: Cookie obtained from xe_vm_set_validating().
 *
 * Register this task as currently making bos resident for the vm. Intended
 * to avoid eviction by the same task of shared bos bound to the vm.
 * Call with the vm's resv lock held.
 */
static inline void xe_vm_clear_validating(struct xe_vm *vm, bool allow_res_evict,
					  struct pin_cookie cookie)
static inline void xe_vm_clear_validating(struct xe_vm *vm, bool allow_res_evict)
{
	if (vm && !allow_res_evict) {
		lockdep_unpin_lock(&xe_vm_resv(vm)->lock.base, cookie);
		/* Pairs with READ_ONCE in xe_vm_is_validating() */
		WRITE_ONCE(vm->validating, NULL);
	}