drm/xe: Rename lookup_vma function to xe_find_vma_by_addr
This update renames the lookup_vma function to xe_vm_find_vma_by_addr and makes it accessible externally. The function, which looks up a VMA by its address within a specified VM, will be utilized in upcoming patches. v2 - Fix doc 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-9-himal.prasad.ghimiray@intel.com Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
This commit is contained in:
@@ -72,28 +72,6 @@ static bool vma_is_valid(struct xe_tile *tile, struct xe_vma *vma)
|
||||
!(BIT(tile->id) & vma->tile_invalidated);
|
||||
}
|
||||
|
||||
static bool vma_matches(struct xe_vma *vma, u64 page_addr)
|
||||
{
|
||||
if (page_addr > xe_vma_end(vma) - 1 ||
|
||||
page_addr + SZ_4K - 1 < xe_vma_start(vma))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static struct xe_vma *lookup_vma(struct xe_vm *vm, u64 page_addr)
|
||||
{
|
||||
struct xe_vma *vma = NULL;
|
||||
|
||||
if (vm->usm.last_fault_vma) { /* Fast lookup */
|
||||
if (vma_matches(vm->usm.last_fault_vma, page_addr))
|
||||
vma = vm->usm.last_fault_vma;
|
||||
}
|
||||
if (!vma)
|
||||
vma = xe_vm_find_overlapping_vma(vm, page_addr, SZ_4K);
|
||||
|
||||
return vma;
|
||||
}
|
||||
|
||||
static int xe_pf_begin(struct drm_exec *exec, struct xe_vma *vma,
|
||||
bool atomic, unsigned int id)
|
||||
@@ -231,7 +209,7 @@ static int handle_pagefault(struct xe_gt *gt, struct pagefault *pf)
|
||||
goto unlock_vm;
|
||||
}
|
||||
|
||||
vma = lookup_vma(vm, pf->page_addr);
|
||||
vma = xe_vm_find_vma_by_addr(vm, pf->page_addr);
|
||||
if (!vma) {
|
||||
err = -EINVAL;
|
||||
goto unlock_vm;
|
||||
|
||||
@@ -2139,6 +2139,35 @@ int xe_vm_destroy_ioctl(struct drm_device *dev, void *data,
|
||||
return err;
|
||||
}
|
||||
|
||||
static bool vma_matches(struct xe_vma *vma, u64 page_addr)
|
||||
{
|
||||
if (page_addr > xe_vma_end(vma) - 1 ||
|
||||
page_addr + SZ_4K - 1 < xe_vma_start(vma))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* xe_vm_find_vma_by_addr() - Find a VMA by its address
|
||||
*
|
||||
* @vm: the xe_vm the vma belongs to
|
||||
* @page_addr: address to look up
|
||||
*/
|
||||
struct xe_vma *xe_vm_find_vma_by_addr(struct xe_vm *vm, u64 page_addr)
|
||||
{
|
||||
struct xe_vma *vma = NULL;
|
||||
|
||||
if (vm->usm.last_fault_vma) { /* Fast lookup */
|
||||
if (vma_matches(vm->usm.last_fault_vma, page_addr))
|
||||
vma = vm->usm.last_fault_vma;
|
||||
}
|
||||
if (!vma)
|
||||
vma = xe_vm_find_overlapping_vma(vm, page_addr, SZ_4K);
|
||||
|
||||
return vma;
|
||||
}
|
||||
|
||||
static const u32 region_to_mem_type[] = {
|
||||
XE_PL_TT,
|
||||
XE_PL_VRAM0,
|
||||
|
||||
@@ -169,6 +169,8 @@ static inline bool xe_vma_is_userptr(struct xe_vma *vma)
|
||||
!xe_vma_is_cpu_addr_mirror(vma);
|
||||
}
|
||||
|
||||
struct xe_vma *xe_vm_find_vma_by_addr(struct xe_vm *vm, u64 page_addr);
|
||||
|
||||
/**
|
||||
* to_userptr_vma() - Return a pointer to an embedding userptr vma
|
||||
* @vma: Pointer to the embedded struct xe_vma
|
||||
|
||||
Reference in New Issue
Block a user