Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/xe: Reject BO eviction if BO is bound to current VM

This is a follow up fix for
https://patchwork.freedesktop.org/patch/msgid/20241203021929.1919730-1-oak.zeng@intel.com
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 <thomas.hellstrom@linux.intel.com>
Signed-off-by: Oak Zeng <oak.zeng@intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250110210137.3181576-1-oak.zeng@intel.com

authored by

Oak Zeng and committed by
Thomas Hellström
0af944f0 3318ef98

+15
+15
drivers/gpu/drm/xe/xe_bo.c
··· 713 713 goto out; 714 714 } 715 715 716 + /* Reject BO eviction if BO is bound to current VM. */ 717 + if (evict && ctx->resv) { 718 + struct drm_gpuvm_bo *vm_bo; 719 + 720 + drm_gem_for_each_gpuvm_bo(vm_bo, &bo->ttm.base) { 721 + struct xe_vm *vm = gpuvm_to_vm(vm_bo->vm); 722 + 723 + if (xe_vm_resv(vm) == ctx->resv && 724 + xe_vm_in_preempt_fence_mode(vm)) { 725 + ret = -EBUSY; 726 + goto out; 727 + } 728 + } 729 + } 730 + 716 731 /* 717 732 * Failed multi-hop where the old_mem is still marked as 718 733 * TTM_PL_FLAG_TEMPORARY, should just be a dummy move.