summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorHimal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>2025-11-25 10:56:27 +0300
committerHimal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>2025-11-26 13:12:33 +0300
commitdd62fe512d5980e86cdd5b77385012f5659775f0 (patch)
tree84322f79885c3c45318b4d86fc1f7d043e7b2cf1 /drivers
parent0ae006dc48f3748fdee675052bc0e5e87b856ac2 (diff)
downloadlinux-dd62fe512d5980e86cdd5b77385012f5659775f0.tar.xz
drm/xe/svm: Enable UNMAP for VMA merging operations
ALLOW UNMAP of VMAs associated with SVM mappings when the MAP operation is intended to merge adjacent CPU_ADDR_MIRROR VMAs. v2 - Remove mapping exist check in garbage collector Cc: Matthew Brost <matthew.brost@intel.com> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Link: https://patch.msgid.link/20251125075628.1182481-5-himal.prasad.ghimiray@intel.com Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/xe/xe_svm.c3
-rw-r--r--drivers/gpu/drm/xe/xe_vm.c10
-rw-r--r--drivers/gpu/drm/xe/xe_vm_types.h1
3 files changed, 8 insertions, 6 deletions
diff --git a/drivers/gpu/drm/xe/xe_svm.c b/drivers/gpu/drm/xe/xe_svm.c
index e895a95af126..46977ec1e0de 100644
--- a/drivers/gpu/drm/xe/xe_svm.c
+++ b/drivers/gpu/drm/xe/xe_svm.c
@@ -314,9 +314,6 @@ static int xe_svm_range_set_default_attr(struct xe_vm *vm, u64 start, u64 end)
has_default_attr = xe_vma_has_default_mem_attrs(vma);
if (has_default_attr) {
- if (xe_svm_has_mapping(vm, xe_vma_start(vma), xe_vma_end(vma)))
- return 0;
-
start = xe_vma_start(vma);
end = xe_vma_end(vma);
} else if (xe_vma_start(vma) == start && xe_vma_end(vma) == end) {
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 2681039f3221..a7a21966e390 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -2246,8 +2246,10 @@ vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_vma_ops *vops,
switch (operation) {
case DRM_XE_VM_BIND_OP_MAP:
- if (flags & DRM_XE_VM_BIND_FLAG_CPU_ADDR_MIRROR)
+ if (flags & DRM_XE_VM_BIND_FLAG_CPU_ADDR_MIRROR) {
xe_vm_find_cpu_addr_mirror_vma_range(vm, &range_start, &range_end);
+ vops->flags |= XE_VMA_OPS_FLAG_ALLOW_SVM_UNMAP;
+ }
fallthrough;
case DRM_XE_VM_BIND_OP_MAP_USERPTR: {
@@ -2729,7 +2731,8 @@ static int vm_bind_ioctl_ops_parse(struct xe_vm *vm, struct drm_gpuva_ops *ops,
if (xe_vma_is_cpu_addr_mirror(vma) &&
xe_svm_has_mapping(vm, xe_vma_start(vma),
- xe_vma_end(vma)))
+ xe_vma_end(vma)) &&
+ !(vops->flags & XE_VMA_OPS_FLAG_ALLOW_SVM_UNMAP))
return -EBUSY;
if (!xe_vma_is_cpu_addr_mirror(vma))
@@ -4315,6 +4318,8 @@ static int xe_vm_alloc_vma(struct xe_vm *vm,
if (is_madvise)
vops.flags |= XE_VMA_OPS_FLAG_MADVISE;
+ else
+ vops.flags |= XE_VMA_OPS_FLAG_ALLOW_SVM_UNMAP;
err = vm_bind_ioctl_ops_parse(vm, ops, &vops);
if (err)
@@ -4391,7 +4396,6 @@ int xe_vm_alloc_madvise_vma(struct xe_vm *vm, uint64_t start, uint64_t range)
static bool is_cpu_addr_vma_with_default_attr(struct xe_vma *vma)
{
return vma && xe_vma_is_cpu_addr_mirror(vma) &&
- !xe_svm_has_mapping(xe_vma_vm(vma), xe_vma_start(vma), xe_vma_end(vma)) &&
xe_vma_has_default_mem_attrs(vma);
}
diff --git a/drivers/gpu/drm/xe/xe_vm_types.h b/drivers/gpu/drm/xe/xe_vm_types.h
index ccd6cc090309..3bf912bfbdcc 100644
--- a/drivers/gpu/drm/xe/xe_vm_types.h
+++ b/drivers/gpu/drm/xe/xe_vm_types.h
@@ -467,6 +467,7 @@ struct xe_vma_ops {
#define XE_VMA_OPS_FLAG_MADVISE BIT(1)
#define XE_VMA_OPS_ARRAY_OF_BINDS BIT(2)
#define XE_VMA_OPS_FLAG_SKIP_TLB_WAIT BIT(3)
+#define XE_VMA_OPS_FLAG_ALLOW_SVM_UNMAP BIT(4)
u32 flags;
#ifdef TEST_VM_OPS_ERROR
/** @inject_error: inject error to test error handling */