drm/xe/svm: Add xe_svm_find_vma_start() helper

Add helper xe_svm_find_vma_start() function to determine start of cpu
vma in input range.

Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Acked-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Link: https://lore.kernel.org/r/20250513040228.470682-14-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-05-13 09:32:26 +05:30
parent 72fa870957
commit c904d4e2d7
2 changed files with 30 additions and 0 deletions

View File

@ -692,6 +692,28 @@ bool xe_svm_range_validate(struct xe_vm *vm,
return ret;
}
/**
* xe_svm_find_vma_start - Find start of CPU VMA
* @vm: xe_vm pointer
* @start: start address
* @end: end address
* @vma: Pointer to struct xe_vma
*
*
* This function searches for a cpu vma, within the specified
* range [start, end] in the given VM. It adjusts the range based on the
* xe_vma start and end addresses. If no cpu VMA is found, it returns ULONG_MAX.
*
* Return: The starting address of the VMA within the range,
* or ULONG_MAX if no VMA is found
*/
u64 xe_svm_find_vma_start(struct xe_vm *vm, u64 start, u64 end, struct xe_vma *vma)
{
return drm_gpusvm_find_vma_start(&vm->svm.gpusvm,
max(start, xe_vma_start(vma)),
min(end, xe_vma_end(vma)));
}
#if IS_ENABLED(CONFIG_DRM_XE_DEVMEM_MIRROR)
static struct xe_vram_region *tile_to_vr(struct xe_tile *tile)
{

View File

@ -89,6 +89,8 @@ bool xe_svm_range_validate(struct xe_vm *vm,
struct xe_svm_range *range,
u8 tile_mask, bool devmem_preferred);
u64 xe_svm_find_vma_start(struct xe_vm *vm, u64 addr, u64 end, struct xe_vma *vma);
/**
* xe_svm_range_has_dma_mapping() - SVM range has DMA mapping
* @range: SVM range
@ -297,6 +299,12 @@ bool xe_svm_range_validate(struct xe_vm *vm,
return false;
}
static inline
u64 xe_svm_find_vma_start(struct xe_vm *vm, u64 addr, u64 end, struct xe_vma *vma)
{
return ULONG_MAX;
}
#define xe_svm_assert_in_notifier(...) do {} while (0)
#define xe_svm_range_has_dma_mapping(...) false