Skip to content

Commit da05e5d

Browse files
committed
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>
1 parent bd1d1b4 commit da05e5d

File tree

3 files changed

+32
-23
lines changed

3 files changed

+32
-23
lines changed

drivers/gpu/drm/xe/xe_gt_pagefault.c

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -72,28 +72,6 @@ static bool vma_is_valid(struct xe_tile *tile, struct xe_vma *vma)
7272
!(BIT(tile->id) & vma->tile_invalidated);
7373
}
7474

75-
static bool vma_matches(struct xe_vma *vma, u64 page_addr)
76-
{
77-
if (page_addr > xe_vma_end(vma) - 1 ||
78-
page_addr + SZ_4K - 1 < xe_vma_start(vma))
79-
return false;
80-
81-
return true;
82-
}
83-
84-
static struct xe_vma *lookup_vma(struct xe_vm *vm, u64 page_addr)
85-
{
86-
struct xe_vma *vma = NULL;
87-
88-
if (vm->usm.last_fault_vma) { /* Fast lookup */
89-
if (vma_matches(vm->usm.last_fault_vma, page_addr))
90-
vma = vm->usm.last_fault_vma;
91-
}
92-
if (!vma)
93-
vma = xe_vm_find_overlapping_vma(vm, page_addr, SZ_4K);
94-
95-
return vma;
96-
}
9775

9876
static int xe_pf_begin(struct drm_exec *exec, struct xe_vma *vma,
9977
bool atomic, unsigned int id)
@@ -231,7 +209,7 @@ static int handle_pagefault(struct xe_gt *gt, struct pagefault *pf)
231209
goto unlock_vm;
232210
}
233211

234-
vma = lookup_vma(vm, pf->page_addr);
212+
vma = xe_vm_find_vma_by_addr(vm, pf->page_addr);
235213
if (!vma) {
236214
err = -EINVAL;
237215
goto unlock_vm;

drivers/gpu/drm/xe/xe_vm.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,6 +2139,35 @@ int xe_vm_destroy_ioctl(struct drm_device *dev, void *data,
21392139
return err;
21402140
}
21412141

2142+
static bool vma_matches(struct xe_vma *vma, u64 page_addr)
2143+
{
2144+
if (page_addr > xe_vma_end(vma) - 1 ||
2145+
page_addr + SZ_4K - 1 < xe_vma_start(vma))
2146+
return false;
2147+
2148+
return true;
2149+
}
2150+
2151+
/**
2152+
* xe_vm_find_vma_by_addr() - Find a VMA by its address
2153+
*
2154+
* @vm: the xe_vm the vma belongs to
2155+
* @page_addr: address to look up
2156+
*/
2157+
struct xe_vma *xe_vm_find_vma_by_addr(struct xe_vm *vm, u64 page_addr)
2158+
{
2159+
struct xe_vma *vma = NULL;
2160+
2161+
if (vm->usm.last_fault_vma) { /* Fast lookup */
2162+
if (vma_matches(vm->usm.last_fault_vma, page_addr))
2163+
vma = vm->usm.last_fault_vma;
2164+
}
2165+
if (!vma)
2166+
vma = xe_vm_find_overlapping_vma(vm, page_addr, SZ_4K);
2167+
2168+
return vma;
2169+
}
2170+
21422171
static const u32 region_to_mem_type[] = {
21432172
XE_PL_TT,
21442173
XE_PL_VRAM0,

drivers/gpu/drm/xe/xe_vm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ static inline bool xe_vma_is_userptr(struct xe_vma *vma)
169169
!xe_vma_is_cpu_addr_mirror(vma);
170170
}
171171

172+
struct xe_vma *xe_vm_find_vma_by_addr(struct xe_vm *vm, u64 page_addr);
173+
172174
/**
173175
* to_userptr_vma() - Return a pointer to an embedding userptr vma
174176
* @vma: Pointer to the embedded struct xe_vma

0 commit comments

Comments
 (0)