drm/xe/svm: Extend MAP range to reduce vma fragmentation

When DRM_XE_VM_BIND_FLAG_CPU_ADDR_MIRROR is set during VM_BIND_OP_MAP,
the mapping logic now checks adjacent cpu_addr_mirror VMAs with default
attributes and expands the mapping range accordingly. This ensures that
bo_unmap operations ideally target the same area and helps reduce
fragmentation by coalescing nearby compatible VMAs into a single mapping.

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-4-himal.prasad.ghimiray@intel.com
Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
This commit is contained in:
Himal Prasad Ghimiray 2025-11-25 13:26:26 +05:30
parent 4a938d3886
commit 0ae006dc48

View File

@ -2233,6 +2233,7 @@ vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_vma_ops *vops,
struct drm_gpuva_ops *ops;
struct drm_gpuva_op *__op;
struct drm_gpuvm_bo *vm_bo;
u64 range_start = addr;
u64 range_end = addr + range;
int err;
@ -2245,10 +2246,14 @@ 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)
xe_vm_find_cpu_addr_mirror_vma_range(vm, &range_start, &range_end);
fallthrough;
case DRM_XE_VM_BIND_OP_MAP_USERPTR: {
struct drm_gpuvm_map_req map_req = {
.map.va.addr = addr,
.map.va.range = range,
.map.va.addr = range_start,
.map.va.range = range_end - range_start,
.map.gem.obj = obj,
.map.gem.offset = bo_offset_or_userptr,
};