Skip to content

Commit 2354a5d

Browse files
zengshanjunjfvogel
authored andcommitted
drm/xe: Reject BO eviction if BO is bound to current VM
[ Upstream commit 0af944f ] This is a follow up fix for https://patchwork.freedesktop.org/patch/msgid/[email protected] The overall goal is to fail vm_bind when there is memory pressure. See more details in the commit message of above patch. Abbove patch fixes the issue when user pass in a vm_id parameter during gem_create. If user doesn't pass in a vm_id during gem_create, above patch doesn't help. This patch further reject BO eviction (which could be triggered by bo validation) if BO is bound to the current VM. vm_bind could fail due to the eviction failure. The BO to VM reverse mapping structure is used to determine whether BO is bound to VM. v2: Move vm_bo definition from function scope to if(evict) clause (Thomas) Further constraint the condition by adding ctx->resv (Thomas) Add a short comment describe the change. Suggested-by: Thomas Hellström <[email protected]> Signed-off-by: Oak Zeng <[email protected]> Reviewed-by: Thomas Hellström <[email protected]> Signed-off-by: Thomas Hellström <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 6ceef704e2bcef5c75be418ee06699158b3000bd) Signed-off-by: Jack Vogel <[email protected]>
1 parent bf61516 commit 2354a5d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/gpu/drm/xe/xe_bo.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,21 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict,
702702
goto out;
703703
}
704704

705+
/* Reject BO eviction if BO is bound to current VM. */
706+
if (evict && ctx->resv) {
707+
struct drm_gpuvm_bo *vm_bo;
708+
709+
drm_gem_for_each_gpuvm_bo(vm_bo, &bo->ttm.base) {
710+
struct xe_vm *vm = gpuvm_to_vm(vm_bo->vm);
711+
712+
if (xe_vm_resv(vm) == ctx->resv &&
713+
xe_vm_in_preempt_fence_mode(vm)) {
714+
ret = -EBUSY;
715+
goto out;
716+
}
717+
}
718+
}
719+
705720
/*
706721
* Failed multi-hop where the old_mem is still marked as
707722
* TTM_PL_FLAG_TEMPORARY, should just be a dummy move.

0 commit comments

Comments
 (0)